Logo for ammarahmed.ca

Medium

Solutions and thought process for medium difficulty Leetcode problems.

Medium
Jul 27, 2025

19. Remove Nth Node From End of List

Given the head of a linked list, remove the nth node from the end of the list and return its head.

#linked-list
#two-pointers

Medium
Jul 25, 2025

143. Reorder List

You are given the head of a singly linked-list. The list can be represented as:

#linked-list

Medium
Jun 14, 2025

981. Time Based Key

Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp.

#binary-search

Medium
Jun 13, 2025

33. Search in Rotated Sorted Array

There is an integer array nums sorted in ascending order (with distinct values).

#binary-search

Medium
May 27, 2025

74. Search a 2D Matrix

You are given an m x n integer matrix matrix with the following two properties:

#binary-search

Medium
May 26, 2025

167. Two Sum II

Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2 <= numbers.length.

#two-pointers
#math

Medium
May 25, 2025

238. Product of Array Except Self

Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

#arrays
#math

Medium
May 24, 2025

347. Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

#arrays
#hashing

Medium
May 24, 2025

36. Valid Sudoku

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

#matrices
#math