Logo for ammarahmed.ca

Leetcode

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

Hard
Aug 05, 2025

42. Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

#two-pointers

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

Easy
May 27, 2025

20. Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

#stack

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

Easy
May 26, 2025

125. Valid Palindrome

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.

#two-pointers

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

Easy
May 23, 2025

1. Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

#arrays
#hashing

Easy
May 23, 2025

242. Valid Anagram

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

#arrays
#hashing