A worked-out collection of
LeetCode solutions in C++
Every solution has the approach explained, complexity analysis, and clean source — written by Ali while studying data structures and algorithms.
Difficulty mix
Distribution of solved problems by difficulty.
By topic
Algorithmic patterns I've practiced most.
Featured solutions
See all →Trapping Rain Water
Water trapped at position i = min(maxLeft, maxRight) - height[i] Instead of computing maxLeft and maxRight for every position separately, we use two pointers starting from both ends and track running maximums.
Merge k Sorted Lists
You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it.
Minimum Window Substring
Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "". The testcases will be generated such that the answer is unique.