0% found this document useful (0 votes)
21 views7 pages

Essential Leetcode Problems for SDEs

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views7 pages

Essential Leetcode Problems for SDEs

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

I​n 2020, I cracked Amazon as an SDE​

​In 2022, I cracked Google as an SWE​


​In 2024, I cracked LinkedIn (Microsoft) as a Sr. SWE​
​In 2025, I am working as a Sr. Software Engineer at Meta.​

I​f I had to restart doing Leetcode practice and build my basics from 0 in 2025, I won’t solved the​
​3500+ problems available on Leetcode, but I would 100% solve these 90+ from my own notes.​


​ To strengthen my understanding of String & String Algorithms:​
​➧ Longest Palindromic Substring​
​➧ Integer to English Words​
​➧ Compare Version Numbers​
​➧ Longest Substring Without Repeating Characters​
​➧ Find the Closest Palindrome​
​➧ Longest Duplicate Substring​
​➧ String to Integer (atoi)​
​➧ Regular Expression Matching​
​➧ Largest Number​
​➧ Longest Valid Parentheses​
​➧ Interleaving String​
​➧ Decode Ways​
​➧ Reverse Words in a String​
​➧ Wildcard Matching​
​➧ Valid Parenthesis String​
​➧ Remove K Digits​
​➧ Palindrome Partitioning II​
​➧ Decode Ways II​
​➧ Repeated String Match​
​➧ Validate IP Address​
​➧ One Edit Distance​
​➧ Valid Number​
​➧ Substring with Concatenation of All Words​
​➧ Strong Password Checker​
​➧ Fraction to Recurring Decimal​
​➧ Text Justification​
​➧ Shortest Palindrome​
​➧ Making File Names Unique​
​➧ Decoded String at Index​
​➧ Regular Expression Matching​
​➧ Split Array With Same Average​
​➧ Count The Repetitions​

​➤ To strengthen my understanding of Array & Array Manipulation:​



​ Median of Two Sorted Arrays​
​➧ 3Sum​
​➧ Jump Game II​
​➧ Maximum Product Subarray​
​➧ Next Permutation​
​➧ 132 Pattern​
​➧ Maximum Number of Events That Can Be Attended​
​➧ Surrounded Regions​
​➧ Max Points on a Line​
​➧ Next Greater Element III​
​➧ Text Justification​
​➧ Shortest Unsorted Continuous Subarray​
​➧ Reverse Pairs​
​➧ Shortest Subarray with Sum at Least K​
​➧ Shortest Subarray to be Removed to Make Array Sorted​
​➧ Water and Jug Problem​
​➧ Making File Names Unique​
​➧ Self Crossing​
​➧ Non-decreasing Array​
​➧ Continuous Subarray Sum​
​➧ Dungeon Game​
​➧ Wiggle Sort II​
​➧ Ways to Split Array Into Three Subarrays​
​➧ Maximum Non Negative Product in a Matrix​
​➧ Frequency of the Most Frequent Element​
​➧ Maximum Number of Visible Points​
​➧ Closest Room​
​➧ Minimize the Difference Between Target and Chosen Elements​


​ To strengthen my understanding of Hash Table & Hashing:​
​➧ Word Ladder​
​➧ Word Ladder II​
​➧ Longest Substring Without Repeating Characters​
​➧ Fraction to Recurring Decimal​
​➧ Making File Names Unique​
​➧ Substring with Concatenation of All Words​
​➧ Max Points on a Line​
​➧ All O\`one Data Structure​
​➧ Contains Duplicate III​
​➧ Invalid Transactions​
​➧ Count Good Meals​
​➧ Make Sum Divisible by P​
​➧ Line Reflection​
​➤ To strengthen my understanding of Dynamic Programming (DP):​


​ Longest Palindromic Substring​
​➧ Jump Game II​
​➧ Maximum Product Subarray​
​➧ Regular Expression Matching​
​➧ Best Time to Buy and Sell Stock IV​
​➧ Longest Valid Parentheses​
​➧ Interleaving String​
​➧ Decode Ways​
​➧ Wildcard Matching​
​➧ Valid Parenthesis String​
​➧ Dungeon Game​
​➧ Count The Repetitions​
​➧ Palindrome Partitioning II​
​➧ Decode Ways II​
​➧ Maximum Score from Performing Multiplication Operations​
​➧ Super Egg Drop​
​➧ Integer Replacement​
​➧ Split Array With Same Average​
​➧ Largest Multiple of Three​
​➧ Minimize the Difference Between Target and Chosen Elements​
​➧ Maximum Non Negative Product in a Matrix​
​➧ Number of Digit One​

​➤ To strengthen my understanding of Two Pointers Technique:​


​ Compare Version Numbers​
​➧ 3Sum​
​➧ Next Permutation​
​➧ Reverse Words in a String​
​➧ One Edit Distance​
​➧ Shortest Unsorted Continuous Subarray​
​➧ Ways to Split Array Into Three Subarrays​
​➧ Sum of Square Numbers​

​➤ To strengthen my understanding of Binary Search:​


​ Median of Two Sorted Arrays​
​➧ 132 Pattern​
​➧ Search in Rotated Sorted Array II​
​➧ Nth Digit​
​➧ Shortest Subarray with Sum at Least K​

​ Reverse Pairs​
​➧ Closest Room​
​➧ Nth Highest Salary​
​➧ Super Egg Drop​
​➧ Minimum Space Wasted From Packaging​
​➧ Frequency of the Most Frequent Element​
​➧ Longest Duplicate Substring​
​➧ Longest Common Subpath​
​➧ Pow(x, n)​

​➤ To strengthen my understanding of Sorting & Order:​


​ 3Sum​
​➧ Wiggle Sort II​
​➧ Maximum Number of Events That Can Be Attended​
​➧ Reverse Pairs​
​➧ Remove K Digits​
​➧ Invalid Transactions​
​➧ Frequency of the Most Frequent Element​
​➧ Closest Room​

​➤ To strengthen my understanding of Stack & Monotonic Stack:​


​ 132 Pattern​
​➧ Longest Valid Parentheses​
​➧ Valid Parenthesis String​
​➧ Remove K Digits​
​➧ Create Maximum Number​
​➧ Shortest Unsorted Continuous Subarray​
​➧ Decoded String at Index​

​➤ To strengthen my understanding of Sliding Window:​


​ Longest Substring Without Repeating Characters​
​➧ Substring with Concatenation of All Words​
​➧ Contains Duplicate III​
​➧ Longest Duplicate Substring​
​➧ Frequency of the Most Frequent Element​
​➧ Maximum Number of Visible Points​

​➤ To strengthen my understanding of Tree & Graph (including BFS/DFS/Topological Sort):​


​ Alien Dictionary​
​➧ Validate Binary Search Tree​

​ Redundant Connection II​
​➧ Kth Ancestor of a Tree Node​
​➧ Surrounded Regions​
​➧ Water and Jug Problem​

​➤ To strengthen my understanding of Greedy Algorithms:​


​ Maximum Product Subarray​
​➧ Largest Number​
​➧ Strong Password Checker​
​➧ Valid Parenthesis String​
​➧ Remove K Digits​
​➧ Maximum Number of Events That Can Be Attended​
​➧ Split Array With Same Average​
​➧ Create Maximum Number​
​➧ Frequency of the Most Frequent Element​
​➧ Sell Diminishing-Valued Colored Balls​

​➤ To strengthen my understanding of Math & Number Theory:​


​ Integer to English Words​
​➧ Find the Closest Palindrome​
​➧ Prime Palindrome​
​➧ Pow(x, n)​
​➧ Fraction to Recurring Decimal​
​➧ Next Greater Element III​
​➧ Sum of Square Numbers​
​➧ Nth Digit​
​➧ Self Crossing​
​➧ Maximum Number of Visible Points​
​➧ Make Sum Divisible by P​
​➧ Number of Digit One​
​➧ Sell Diminishing-Valued Colored Balls​

​➤ To strengthen my understanding of Heap / Priority Queue:​


​ Maximum Number of Events That Can Be Attended​
​➧ Sell Diminishing-Valued Colored Balls​
​➧ Design Twitter​
​➧ Strong Password Checker​

​➤ To strengthen my understanding of Linked List:​



​ Rotate List​
​➧ All O\`one Data Structure​
​➧ Insert into a Sorted Circular Linked List​
​➧ Design Linked List​
​➧ Design Twitter​

​➤ To strengthen my understanding of Bit Manipulation / Bitmask:​


​ Divide Two Integers​
​➧ Split Array With Same Average​
​➧ Integer Replacement​

​➤ To strengthen my understanding of Design / System Design:​


​ All O\`one Data Structure​
​➧ Design Twitter​
​➧ Design Linked List​
​➧ Kth Ancestor of a Tree Node​

​➤ To strengthen my understanding of Database / SQL:​


​ Nth Highest Salary​
​➧ Word Frequency​

​➤ To strengthen my understanding of Other Advanced Patterns:​

​↝Rolling Hash / Suffix Array / Hash Function:​


​➧ Longest Duplicate Substring​
​➧ Shortest Palindrome​
​➧ Longest Common Subpath​

​↝Divide and Conquer:​


​➧ Median of Two Sorted Arrays​
​➧ Reverse Pairs​
​➧ Wiggle Sort II​

​↝Union Find:​
​➧ Surrounded Regions​
​➧ Redundant Connection II​

​↝Geometry:​

​ Max Points on a Line​
​➧ Self Crossing​
​➧ Maximum Number of Visible Points​

Common questions

Powered by AI

The Longest Palindromic Substring problem uses dynamic programming to efficiently track and calculate palindromic substrings by maintaining a two-dimensional DP table, where each cell at index (i, j) indicates whether the substring from index i to j forms a palindrome. This avoids the need to repeatedly check the same substrings, which would otherwise result in a time complexity of O(n^3). Instead, by leveraging previously computed results, the overall complexity reduces to O(n^2).

The Sliding Window technique enables solving the Longest Substring Without Repeating Characters problem efficiently by dynamically adjusting the starting and ending indices of the window. By expanding the window with a non-repeating character and contracting it when a repeat is found, the substring's length is optimized in linear time, O(n), as each character is processed only a few times .

The DP approach to "Decode Ways" effectively utilizes memoization by keeping a record of computed results for subproblems, thus avoiding redundant calculations performed in recursive solutions. This tabulation-based strategy considerably cuts down from exponential time O(2^n) to linear O(n) complexity. Compared to exhaustive recursion, DP's awareness of overlapping sub-problems grants it significant performance superiority, especially for larger input sizes .

In the "Word Ladder" problem, hash tables offer an efficient way of storing and retrieving each intermediate word state, allowing quick checks and transformations between possible word sequences. This approach reduces redundant processing since each word transformation is recorded and referenced, limiting the broad search space typical in simple BFS, resulting in significant performance improvements with a time complexity of O(M^2 * N).

The "Dungeon Game" problem presents challenges in determining the minimum initial strength required through a grid traversal, requiring carefully structured DP solutions. A critical challenge is setting correct conditions at each grid cell based on remaining health points, which are addressed by reverse traversing the grid and maintaining a DP table of minimum health needed, backward from the goal to the start. This ensures decisions are made with future path requirements in mind, achieving an O(m*n) solution .

The 3Sum problem benefits from the two pointers technique as it allows for an O(n^2) solution by first sorting the array and then using two pointers to simultaneously search the subarray for pairs summing to a target value (the negative of the current element). This technique avoids the need to resort to a more computationally expensive O(n^3) triple nested loop, as managing these two pointers helps in narrowing down the possibilities quickly and efficiently .

Binary search is crucial in solving the "Median of Two Sorted Arrays" by applying it to the smaller of the two arrays to partition both arrays in a way that elements left to the partition make up the left half of the median and those right make up the right half. This method drastically reduces the complexity from a naive O(m + n) to O(log(min(m, n))), as it eliminates whole chunks of potential median candidates in each step of the binary search .

The "Fraction to Recurring Decimal" problem utilizes hash maps to detect the start and end of repeating decimal sequences by tracking remainders. Each remainder is mapped to its corresponding position in the result sequence. This mapping is essential because remainders that repeat indicate the beginning of a recurring cycle, allowing us to enclose this sequence in parentheses, hence accurately representing recurring decimals .

Using a heap or priority queue in the "Maximum Number of Events That Can Be Attended" problem allows for efficient selection of events by prioritizing event ending times. The greediness in selecting events with the earliest finishing time ensures that more events can be attended as the end time of one event directly affects the start time of the next available event. This approach ensures that events are processed in optimal order by maintaining event duration information in O(n log n) complexity .

The Greedy Algorithm in the "Remove K Digits" exploits a sequential minimization approach by iteratively comparing and removing higher digits when smaller ones come after, to achieve minimum resultant number optimally. This approach leverages locally optimal choices, leading to a globally optimal solution with reduced computational overhead, operating in linear O(n) complexity instead of more costly combinatorial solutions .

You might also like