Logo for ammarahmed.ca

Leetcode

Showcasing my solutions to Leetcode problems in Go alongside my thought process and approach to solving them.

Medium
Jul 28, 2025

2. Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

#linked-list

Medium
Jul 27, 2025

138. Copy List with Random Pointer

A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.

#linked-list

Medium
Jun 12, 2025

853. Car Fleet

There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.

#stack
#sorting

Medium
Jun 12, 2025

739. Daily Temperatures

Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.

#stack

Medium
May 27, 2025

15. 3Sum

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

#two-pointers
#math

Easy
May 27, 2025

121. Best Time to Buy and Sell Stock

You are given an array prices where prices[i] is the price of a given stock on the ith day.

#sliding-window

Easy
May 27, 2025

704. Binary Search

Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

#binary-search

Medium
May 27, 2025

11. Container With Most Water

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

#two-pointer
#math


Easy
May 23, 2025

217. Contains Duplicate

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

#arrays
#hashing