{"id":1101,"date":"2026-04-04T14:13:51","date_gmt":"2026-04-04T08:43:51","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=1101"},"modified":"2026-10-28T15:11:40","modified_gmt":"2026-10-28T09:41:40","slug":"dsa-interview-cheat-sheet","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/dsa-interview-cheat-sheet\/","title":{"rendered":"DSA Interview Cheat Sheet: All Patterns You Need to Know"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Most <strong>DSA interviews<\/strong> test the same set of <strong>patterns<\/strong> again and again. Whether it is <strong>TCS, Infosys, Amazon, Google<\/strong>, or any startup, the problems change but the underlying <strong>patterns stay the same<\/strong>. If you learn to <strong>recognize these patterns<\/strong>, you can solve most interview problems without memorizing <strong>hundreds of questions<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This cheat sheet covers every <strong>major DSA pattern<\/strong>, when to use it, what type of problems fall under it, and the <strong>key idea behind each one<\/strong>. Bookmark this page and come back to it before every interview.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every problem below links to our written solution, the problem page on LeetCode or GeeksforGeeks so you can solve it yourself, and a video walkthrough on the <a href=\"https:\/\/www.youtube.com\/@codeanddebug\" target=\"_blank\" rel=\"noreferrer noopener\">Code and Debug YouTube channel<\/a> where one is available. Want the complete problem list in order? Follow it in our <a href=\"https:\/\/codeanddebug.in\/course\/master-dsa-with-leetcode\">Master DSA with LeetCode<\/a> course.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Patterns Matter More Than Problems<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A lot of students make the mistake of solving <strong>500+ LeetCode problems randomly<\/strong>. They solve a problem, feel good, and move to the next one. But when a slightly different version shows up in an interview, they get stuck.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The reason is simple. They <strong>memorized solutions instead of understanding patterns<\/strong>. Once you know a pattern, you can apply it to <strong>20 or 30 different problems<\/strong>. That is a much better use of your time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of it this way. If someone asks you to find <strong>two numbers that add up to a target in a sorted array<\/strong>, and you know the <strong>two pointer pattern<\/strong>, you do not need to have seen that exact problem before. You just <strong>recognize the pattern and apply it<\/strong>. Same goes for finding the <strong>longest substring without repeating characters<\/strong>. If you know the <strong>sliding window<\/strong>, the problem is <strong>half solved before you even start coding<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The patterns listed below cover roughly <strong>90% of what you will face in interviews<\/strong> at <strong>Indian product companies, service companies, and startups<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Two Pointers<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>two pointer pattern<\/strong> uses two variables (usually called <strong>left and right<\/strong>) that move through an array or string from different positions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The input is <strong>sorted<\/strong><\/li>\n\n\n\n<li>You need to find <strong>pairs or triplets<\/strong> that satisfy a condition<\/li>\n\n\n\n<li>Useful when comparing elements from <strong>both ends of an array<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Two Sum (sorted array)<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/two-sum-leetcode-1\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/two-sum\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/EX2tR_cgCz4\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Three Sum<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/3sum-leetcode-15\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/3sum\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/Euky4JTEK0I\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Remove Duplicates from Sorted Array<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/remove-duplicates-from-sorted-array\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/a2gP9uYrpQo\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Trapping Rain Water<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/trapping-rain-water\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/trapping-rain-water\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><br>Instead of checking every possible pair using <strong>two nested loops (O(n\u00b2))<\/strong>, you use two pointers that move towards each other based on some condition. This reduces the time complexity to <strong>O(n)<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to spot it:<\/strong><br>If the problem says <strong>&#8220;sorted array&#8221;<\/strong> and asks you to find a <strong>pair or group of elements<\/strong>, think <strong>two pointers first<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Sliding Window<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sliding window<\/strong> is one of the <strong>most frequently asked patterns<\/strong> in interviews. It works on problems where you need to find something (<strong>maximum, minimum, count<\/strong>) within a <strong>contiguous subarray or substring<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The problem involves a <strong>subarray or substring<\/strong><\/li>\n\n\n\n<li>You need to optimize from a <strong>brute force approach<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Maximum Sum Subarray of Size K<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/max-sum-subarray-of-size-k5313\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Longest Substring Without Repeating Characters<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/longest-substring-without-repeating-characters\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/longest-substring-without-repeating-characters\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/_zpYpeIREPE\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Minimum Window Substring<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/minimum-window-substring\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Fruits Into Baskets<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/fruit-into-baskets\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/fruit-into-baskets\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/bXM1YNPmrwo\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Longest Repeating Character Replacement<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/longest-repeating-character-replacement\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/longest-repeating-character-replacement\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><br>Maintain a <strong>window (two pointers)<\/strong> and <strong>expand or shrink<\/strong> it based on conditions. As the window slides forward, you <strong>add new elements and remove old ones<\/strong>, avoiding recomputation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Fixed window vs variable window:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Fixed window:<\/strong> Size is given (e.g., size K)<\/li>\n\n\n\n<li><strong>Variable window:<\/strong> Find smallest\/largest window satisfying a condition<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Binary Search<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Binary search<\/strong> is not just about searching in a <strong>sorted array<\/strong>. Its real power is <strong>search space reduction<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input is <strong>sorted<\/strong><\/li>\n\n\n\n<li>You are searching in a <strong>monotonic space<\/strong> (increasing\/decreasing)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Search in Rotated Sorted Array<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/search-in-rotated-sorted-array\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/search-in-rotated-sorted-array\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/46kRvrls5xM\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Find Minimum in Rotated Sorted Array<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/find-minimum-in-rotated-sorted-array\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/find-minimum-in-rotated-sorted-array\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/_B2JakopXLc\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Koko Eating Bananas<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/koko-eating-bananas-leetcode-875\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/koko-eating-bananas\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Median of Two Sorted Arrays<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/median-of-two-sorted-arrays\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/median-of-two-sorted-arrays\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Aggressive Cows<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/aggresive-cows\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/aggressive-cows\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Book Allocation Problem<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/allocate-minimum-pages\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/allocate-minimum-number-of-pages0937\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><br>Check the <strong>middle element<\/strong> and eliminate <strong>half of the search space<\/strong> each time \u2192 <strong>O(log n)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important for Indian interviews:<\/strong><br>Problems like <strong>Book Allocation, Aggressive Cows, Painter&#8217;s Partition<\/strong> are extremely common. These are <strong>&#8220;binary search on answer&#8221;<\/strong> problems where you search on the <strong>answer space instead of the array<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Hashing<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Hashing<\/strong> is the go-to technique when you need <strong>fast lookups, counting, or tracking elements<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Need <strong>O(1) lookup<\/strong><\/li>\n\n\n\n<li>Counting <strong>frequency of elements<\/strong><\/li>\n\n\n\n<li>Checking if something <strong>exists<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Two Sum (unsorted)<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/two-sum-leetcode-1\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/two-sum\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/EX2tR_cgCz4\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Longest Consecutive Sequence<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/longest-consecutive-sequence\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/longest-consecutive-sequence\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/OO2FsBeFcEs\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Subarray Sum Equals K<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/subarray-sum-equals-k\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Valid Anagram<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/valid-anagram\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/valid-anagram\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/EnrE4tnmYZo\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><br>Use a <strong>hash map (dictionary)<\/strong> to store elements and their properties (index, frequency, etc.), converting slow lookups into <strong>O(1)<\/strong> operations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Watch out for:<\/strong><br>Worst-case <strong>hash collisions<\/strong>, but in interviews, <strong>average O(1)<\/strong> is what matters.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Stack and Queue<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Stack problems<\/strong> usually involve <strong>matching or tracking elements in order<\/strong>. The <strong>monotonic stack<\/strong> is a very important subpattern.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Matching <strong>brackets<\/strong><\/li>\n\n\n\n<li>Finding <strong>next greater\/smaller elements<\/strong><\/li>\n\n\n\n<li>Evaluating expressions<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Valid Parentheses<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/valid-parentheses\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/valid-parentheses\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/mnNsoWg2IO0\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Next Greater Element<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/next-larger-element\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/next-larger-element-1587115620\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td><a href=\"https:\/\/youtu.be\/i7N07gXrqh0\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Daily Temperatures<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/daily-temperatures\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Largest Rectangle in Histogram<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/largest-rectangle-in-histogram\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Min Stack<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/min-stack\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/min-stack\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/8BZDEeY-yUc\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Evaluate Reverse Polish Notation<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/evaluate-reverse-polish-notation\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Implement Queue Using Stacks<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/implement-queue-using-stacks\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/1U-FKK4p6VE\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stack \u2192 <strong>Last In First Out (LIFO)<\/strong><\/li>\n\n\n\n<li>Monotonic stack \u2192 maintain <strong>increasing or decreasing order<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Monotonic stack trick:<\/strong><br>For every element, <strong>pop elements that are smaller (or larger)<\/strong>. The remaining top gives the answer.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. Linked List Patterns<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Linked list problems test <strong>pointer manipulation skills<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Problem involves a <strong>linked list<\/strong><\/li>\n\n\n\n<li>Need <strong>in-place rearrangement<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Reverse Linked List<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/reverse-linked-list-leetcode-206\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/reverse-linked-list\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/8DJwQV3fjuI\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Detect Cycle<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/linked-list-cycle-leetcode-141\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/linked-list-cycle\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/2MlUoKhIjA0\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Find Middle<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/middle-of-the-linked-list-leetcode-876\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/middle-of-the-linked-list\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/7YEZjO03JwA\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Merge Two Sorted Lists<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/merge-two-sorted-lists\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Remove Nth Node from End<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/remove-nth-node-from-end-of-list-leetcode-19\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/remove-nth-node-from-end-of-list\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/L7_0FCrajUA\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Palindrome Linked List<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/palindrome-linked-list-leetcode-234\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/palindrome-linked-list\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Intersection of Two Linked Lists<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/intersection-of-two-linked-lists-leetcode-160\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/intersection-of-two-linked-lists\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key tricks:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Slow and fast pointer<\/strong> (middle, cycle detection)<\/li>\n\n\n\n<li><strong>Reverse technique<\/strong><\/li>\n\n\n\n<li><strong>Dummy node<\/strong> (simplifies edge cases)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>7. Trees (BFS and DFS)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Tree problems are extremely common and mostly follow <strong>BFS or DFS<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use BFS:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Level order traversal<\/strong><\/li>\n\n\n\n<li><strong>Shortest path<\/strong><\/li>\n\n\n\n<li>Process nodes <strong>level by level<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use DFS:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Path-based problems<\/strong><\/li>\n\n\n\n<li>Checking <strong>tree properties<\/strong><\/li>\n\n\n\n<li>Computing <strong>depth<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Maximum Depth<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/maximum-depth-of-binary-tree\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/maximum-depth-of-binary-tree\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/qYMxdq2abD8\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Level Order Traversal<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/breadth-first-search-in-binary-trees\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/binary-tree-level-order-traversal\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/tRhWzxU-oH0\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Validate BST<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/validate-binary-search-tree\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/ah604p9o5rA\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Lowest Common Ancestor<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/lowest-common-ancestor-of-a-binary-tree\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Diameter<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/diameter-of-binary-tree\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/diameter-of-binary-tree\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/KsADe9oiK1A\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Right Side View<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/binary-tree-right-side-view\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/binary-tree-right-side-view\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/91dm6RRruhM\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Zigzag Traversal<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/binary-tree-zigzag-level-order-traversal\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/binary-tree-zigzag-level-order-traversal\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea (DFS):<\/strong><br>Ask:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What do I need from the <strong>left subtree<\/strong>?<\/li>\n\n\n\n<li>What do I need from the <strong>right subtree<\/strong>?<\/li>\n\n\n\n<li>How do I <strong>combine them<\/strong>?<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea (BFS):<\/strong><br>Use a <strong>queue<\/strong> and process nodes <strong>level by level<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>8. Graph Traversal<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Graphs extend trees with <strong>cycles and multiple paths<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Problems involving <strong>connections, grids, networks<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Number of Islands<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/number-of-islands-leetcode-200\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/number-of-islands\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/_vh_eWEiEl8\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Course Schedule<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/course-schedule-1\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/course-schedule\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/q2mquGGPmwI\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Rotten Oranges<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/rotting-oranges-leetcode-994\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/rotting-oranges\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/sBspSzNU7Oc\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Word Ladder<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/word-ladder-leetcode-127\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/word-ladder\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/hxZQY5U__NM\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Number of Provinces<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/number-of-provinces\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td><a href=\"https:\/\/youtu.be\/SOmFfGoaW1w\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Surrounded Regions<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/surrounded-regions-leetcode-130\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/surrounded-regions\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/n05WmMKTcGo\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Topological Sort<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/topo-sort-kahns-algorithm\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/topological-sort\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td><a href=\"https:\/\/youtu.be\/I5E89BRSQ-o\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key ideas:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Track <strong>visited nodes<\/strong><\/li>\n\n\n\n<li>BFS \u2192 <strong>shortest path<\/strong><\/li>\n\n\n\n<li>DFS \u2192 <strong>connected components<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Topological sort:<\/strong><br>Used for <strong>task ordering with dependencies<\/strong> (Kahn\u2019s algorithm or DFS).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>9. Recursion and Backtracking<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Backtracking is <strong>recursion with undoing choices<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Find <strong>all combinations, permutations, subsets<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Subsets<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/print-all-subsequences\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/subsets\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/wNp_FS1Sa_c\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Permutations<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/permutations\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Combination Sum<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/combination-sum\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/combination-sum\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/98-CzNc1O6M\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>N Queens<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/n-queens\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/n-queens\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/BxSXlYzXWAk\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Sudoku Solver<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/sudoku-solver\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Word Search<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/word-search\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Palindrome Partitioning<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/palindrome-partitioning\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><br>Think of it as a <strong>decision tree<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Template:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Define <strong>base case<\/strong><\/li>\n\n\n\n<li>Loop through choices<\/li>\n\n\n\n<li><strong>Make a choice<\/strong><\/li>\n\n\n\n<li><strong>Recurse<\/strong><\/li>\n\n\n\n<li><strong>Undo choice (backtrack)<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pruning:<\/strong><br>Skip invalid paths early to improve performance.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>10. Dynamic Programming<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Dynamic Programming (DP)<\/strong> is <strong>optimized recursion<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Overlapping subproblems<\/strong><\/li>\n\n\n\n<li><strong>Optimal substructure<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Climbing Stairs<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/climbing-stairs-leetcode-70\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/climbing-stairs\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/VB_Qj4VWYRg\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>House Robber<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/house-robber\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/house-robber\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/eyRPBmmUAc4\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Longest Common Subsequence (LCS)<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/longest-common-subsequence\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/longest-common-subsequence\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/GLlFa1Lo73c\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>0\/1 Knapsack<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/0-1-knapsack-problem\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/0-1-knapsack-problem0945\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td><a href=\"https:\/\/youtu.be\/pqL1iTVUyes\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Edit Distance<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/edit-distance\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Coin Change<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/coin-change\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Matrix Chain Multiplication<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/matrix-chain-multiplication0303\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Approach:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start with <strong>recursion<\/strong><\/li>\n\n\n\n<li>Identify <strong>state variables<\/strong><\/li>\n\n\n\n<li>Add <strong>memoization<\/strong><\/li>\n\n\n\n<li>Convert to <strong>tabulation<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common categories:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>1D DP (Linear)<\/strong><\/li>\n\n\n\n<li><strong>2D DP (Grid)<\/strong><\/li>\n\n\n\n<li><strong>String DP<\/strong><\/li>\n\n\n\n<li><strong>Knapsack variants<\/strong><\/li>\n\n\n\n<li><strong>Interval DP<\/strong><\/li>\n\n\n\n<li><strong>Tree DP<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important for Indian interviews:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>0\/1 Knapsack and variants<\/strong><\/li>\n\n\n\n<li><strong>Longest Common Subsequence (LCS)<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>11. Greedy<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Greedy algorithms<\/strong> make the <strong>best local choice<\/strong> at each step.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>When <strong>local optimal \u2192 global optimal<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Fractional Knapsack<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/fractional-knapsack\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/fractional-knapsack-1587115620\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td><a href=\"https:\/\/youtu.be\/K_qtZbLSYm0\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Activity Selection<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/activity-selection-1587115620\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Job Sequencing<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/job-sequencing-problem\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/job-sequencing-problem-1587115620\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Minimum Platforms<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/minimum-platforms\/\">Read<\/a><\/td><td><a href=\"https:\/\/www.geeksforgeeks.org\/problems\/minimum-platforms-1587115620\/1\" target=\"_blank\" rel=\"noreferrer noopener\">GFG<\/a><\/td><td><a href=\"https:\/\/youtu.be\/z5yb0JGi4OE\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Jump Game<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/jump-game\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/jump-game\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/kw8mIiTkLK4\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Gas Station<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/gas-station\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><br>Sort input and make <strong>locally optimal decisions<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>12. Heap \/ Priority Queue<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>heap<\/strong> gives quick access to the <strong>minimum or maximum element<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Kth largest\/smallest problems<\/strong><\/li>\n\n\n\n<li><strong>Top K elements<\/strong><\/li>\n\n\n\n<li><strong>Merging sorted lists<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Kth Largest Element<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/kth-largest-element-in-an-array\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Top K Frequent Elements<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/top-k-frequent-elements\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Merge K Sorted Lists<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/merge-k-sorted-lists\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Find Median from Data Stream<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/find-median-from-data-stream\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Task Scheduler<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/task-scheduler\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key idea:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <strong>min heap \/ max heap<\/strong><\/li>\n\n\n\n<li>Maintain a <strong>heap of size K<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>13. Bit Manipulation<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Less frequent but important for <strong>optimization-heavy problems<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When to use it:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Finding <strong>unique elements<\/strong><\/li>\n\n\n\n<li>Checking <strong>power of 2<\/strong><\/li>\n\n\n\n<li><strong>Bit counting<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common problems:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Article<\/th><th>Solve<\/th><th>Video<\/th><\/tr><\/thead><tbody><tr><td>Single Number<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/single-number\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/single-number\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/K0YpJf2UqN4\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><tr><td>Power of Two<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/power-of-two\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Counting Bits<\/td><td>&#8211;<\/td><td><a href=\"https:\/\/leetcode.com\/problems\/counting-bits\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td>&#8211;<\/td><\/tr><tr><td>Missing Number<\/td><td><a href=\"https:\/\/codeanddebug.in\/blog\/find-the-missing-number\/\">Read<\/a><\/td><td><a href=\"https:\/\/leetcode.com\/problems\/missing-number\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\">LeetCode<\/a><\/td><td><a href=\"https:\/\/youtu.be\/Zo1d2EqX45U\" target=\"_blank\" rel=\"noreferrer noopener\">Watch<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key operations:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AND, OR, XOR, shifts<\/li>\n\n\n\n<li><strong>XOR properties:<\/strong>\n<ul class=\"wp-block-list\">\n<li>a XOR a = 0<\/li>\n\n\n\n<li>a XOR 0 = a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Use This Cheat Sheet<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Do not try to master all patterns at once.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Week 1\u20132:<\/strong> Two Pointers, Sliding Window, Hashing<\/li>\n\n\n\n<li><strong>Week 3\u20134:<\/strong> Binary Search, Stack, Linked List<\/li>\n\n\n\n<li><strong>Week 5\u20136:<\/strong> Trees, Graphs<\/li>\n\n\n\n<li><strong>Week 7\u20138:<\/strong> Recursion, Backtracking, DP<\/li>\n\n\n\n<li><strong>Ongoing:<\/strong> Greedy, Heap, Bit Manipulation<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For each pattern, solve <strong>5 to 8 problems<\/strong>. Focus on <strong>understanding<\/strong>, not memorizing.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>One Last Tip<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After solving a problem, spend <strong>2 minutes<\/strong> asking:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What pattern did I use?<\/strong><\/li>\n\n\n\n<li><strong>How would I recognize this pattern in a new problem?<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This habit builds <strong>pattern recognition faster than solving more problems blindly<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Start Your DSA Journey<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you are just getting started with DSA and Python, check out our <a href=\"https:\/\/codeanddebug.in\/course\/zero-to-hero-python-dsa\">Zero to Hero Python DSA<\/a> course. It covers everything from basics to advanced topics in a structured way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Already comfortable with the fundamentals and want to practice problems pattern by pattern? Our <a href=\"https:\/\/codeanddebug.in\/course\/master-dsa-with-leetcode\">Master DSA with LeetCode<\/a> course walks you through<strong> 150+ handpicked problem<\/strong>s organized exactly by the patterns covered in this cheat sheet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most DSA interviews test the same set of patterns again and again. Whether it is TCS, Infosys, Amazon, Google, or any startup, the problems change but the underlying patterns stay the same. If you learn to recognize these patterns, you can solve most interview problems without memorizing hundreds of questions. This cheat sheet covers every<\/p>\n","protected":false},"author":1,"featured_media":1106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1101","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-structures-and-algorithm"],"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2026\/04\/DSA-Interview-Cheat-Sheet-Banner.png","author_info":{"display_name":"Anirudh Khurana","author_link":"https:\/\/codeanddebug.in\/blog\/author\/codeanddebug\/"},"_links":{"self":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/1101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/comments?post=1101"}],"version-history":[{"count":3,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/1101\/revisions"}],"predecessor-version":[{"id":1186,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/1101\/revisions\/1186"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/1106"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=1101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=1101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=1101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}