Skip to content

BernardMoy/Leetcode-150

Repository files navigation

LeetCode Top Interview 150 Questions

An attempt on the LeetCode 150 questions over summer 2025, categorised into 23 different topics, and designed for mastering coding interviews. This strengthened my skills on data structures and algorithms, as well as technical problem-solving.

The questions can be viewed here.

Language

Python3

Notable questions

The following questions are exceptionally difficult in my opinion, as they require intelligent, problem-specific skills to solve:

Container with most water / Trapping rain water: Two pointers, shrink the side with a smallest height in order to make an attempt to maximise the area.

Product of Array Except Self: Think of using prefix and postfix (precomputed results) when the division operator can't be used.

Majority element: Use a count variable that increments and decrements. The majority element will never cause the count to go below zero towards the end, caused by other elements.

Minimum window substring: Two pointers, instead of comparing two dictionaries everytime, keep a separate required length variable that +1 when a required letter is being removed.

LRU Cache: Implement a heap that get min element in O(1) time: use a doubly linked list where the least called elements are shifted to the left side.

Binary tree max path sum: Maintain a global ans variable to check for bending paths, instead of checking them in the dfs.

Merge k sorted lists: Store the index in the heap to keep every entry distinct.

Bitwise AND of Numbers Range: N & (N-1) unsets the rightmost set bit in N.

Factorial Trailing Zeroes: Get trailing zeroes but recursively computing 5 factors.

Best time to buy and sell stock IV: Maintain 2 DP tables, where sell depends on the value previously bought, and buy depends on the value after selling the previous value.

About

An attempt of Leetcode 150 top interview questions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages