Logo for ammarahmed.ca

Medium

Solutions and thought process for medium difficulty Leetcode problems.

Medium
Jun 13, 2025

153. Find Minimum in Rotated Sorted Array

Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:

#binary-search

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
Jun 12, 2025

875. Koko Eating Bananas

Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.

#binary-search

Medium
Jun 09, 2025

22. Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

#stack
#recursion

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

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


Medium
May 25, 2025

128. Longest Consecutive Sequence

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

#arrays
#math

Medium
May 24, 2025

49. Group Anagrams

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

#arrays
#hashing