Logo for ammarahmed.ca

Leetcode

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

Easy
Oct 06, 2025

226. Invert Binary Tree

Given the root of a binary tree, invert the tree, and return its root.

#binary-tree

Hard
Sep 18, 2025

84. Largest Rectangle in Histogram

Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.

#stack

Medium
Aug 03, 2025

287. Find the Duplicate Number

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

#linked-list

Medium
Jul 27, 2025

424. Longest Repeating Character Replacement

You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times.

#sliding-window

Easy
Jul 24, 2025

141. Linked List Cycle

Given head, the head of a linked list, determine if the linked list has a cycle in it.

#linked-list

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

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 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