🪐 Leetcode DS & Algo Resources
Open in Telegram
Discuss here 😌👉 @leetcoded_discuss What will be shared here ? 😃👇 - Tons of coding resources ❤️ - Interview Experience of people - Trending Coding News - Crack FAANG💪 #compulsory for CS/IT students !! Buy 6 months Linkedin Premium 👉 @dishu_disha
Show moreThe country is not specifiedThe category is not specified
1 091
Subscribers
+824 hours
+427 days
+23630 days
Posts Archive
Best YouTube Channels for Programming🚨🚨
Apna College and Anuj Bhaiya
(Well structure DSA course for beginners )
Aditya Verma
(Specially DP❤️)
Abdul Bari
(Algorithms 💯)
Nick White
Tech Dose
Take you forward
(Trees and Graph playlist💗 )
Pepcoding
Love Babbar
Sliding Window Algorithm !!
This is one of the popular algorithms because of its efficiency.
But do you know, if you understand this algorithm/pattern, you will be able to solve many problems which are a slight variation of the standard algorithm? Thus, it's very important to learn algorithm/pattern and whenever you come across any new problem, try to recognise the pattern.
Slight variations of Sliding Window pattern problems:
https://lnkd.in/d4vNrUdu
https://lnkd.in/dVg49PEc
https://lnkd.in/d2YwauBU
https://lnkd.in/dQjrAcJ5
https://lnkd.in/dHcY5mRe
https://lnkd.in/dMrZYSDS
https://lnkd.in/dEtTUpdx
https://lnkd.in/dugnXyw6
https://lnkd.in/dr-ddg9c
https://lnkd.in/dnCEwpHG
https://lnkd.in/dVg49PEc
https://lnkd.in/d32idnMc
https://lnkd.in/dBi28ey8
https://lnkd.in/dGUFSsFx
Basic template:
1. Expand the window
2. Meet the condition and process the window
3. Contract our window
Some of the resources/blogs that you can check out for building thought process for sliding window algorithm:
1. https://lnkd.in/dVAFkZKw
2. https://lnkd.in/dd3me-mn
3. https://lnkd.in/dqvBsYag
4. https://lnkd.in/dBpBhDfD
Resources to improve Problem Solving on LeetCode
Algorithms by Jeff Erickson - https://www.pdfdrive.com/algorithms-jeff-erickson-e91546043.html
competitive programming 3 - https://www.pdfdrive.com/competitive-programming-3-d32649251.html
Category list of each LC problem by wisdompeak - https://github.com/wisdompeak/LeetCode
Rating list of each LC problem by zerotrac - https://https://lnkd.in/dXTz_tnY
competitive programmers handbook - https://cses.fi/book/book.pdf
𝗦𝗼𝗺𝗲 𝗣𝗮𝘁𝘁𝗲𝗿𝗻𝘀 𝘁𝗼 𝗶𝗱𝗲𝗻𝘁𝗶𝗳𝘆 𝗣𝗿𝗼𝗯𝗹𝗲𝗺𝘀 𝗶𝗻 𝗔𝗻𝘆 𝗖𝗼𝗱𝗶𝗻𝗴 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄
1. Sliding Window
📌 The problem input is a linear data structure such as a linked list, array, or string
📌 You’re asked to find the longest/shortest substring, subarray, or the desired value
2. Two Pointers or Iterators
📌 It will feature problems where you deal with sorted arrays (or Linked Lists) and need to find a set of elements that fulfill certain constraints
📌 The set of elements in the array is a pair, a triplet, or even a subarray
3. Fast and Slow pointers
📌 The problem will deal with a loop in a linked list or array
📌 When you need to know the position of a certain element or the overall length of the linked list.
4. Merge Intervals
📌 If you’re asked to produce a list with only mutually exclusive intervals
📌 If you hear the term “overlapping intervals”.
📌 Intervals Intersection (medium)
📌 Maximum CPU Load (hard)
5. Cyclic sort
📌 They will be problems involving a sorted array with numbers in a given range
📌 If the problem asks you to find the missing/duplicate/smallest number in an sorted/rotated array
6. In-place reversal of linked list
📌 If you’re asked to reverse a linked list without using extra memory
7. Tree BFS
📌 If you’re asked to traverse a tree in a level-by-level fashion (or level order traversal)
8. Tree DFS
📌 If you’re asked to traverse a tree with in-order, preorder, or postorder DFS
📌 If the problem requires searching for something where the node is closer to a leaf
9. Two heaps
📌 Useful in situations like Priority Queue, Scheduling
📌 If the problem states that you need to find the smallest/largest/median elements of a set
📌 Sometimes, useful in problems featuring a binary tree data structure
10. Subsets
📌 Problems where you need to find the combinations or permutations of a given set
📌 Subsets With Duplicates (easy)
📌 String Permutations by changing case (medium)
Fast and Slow pointers
The Fast and Slow pointer approach, also known as the Hare & Tortoise algorithm, is a pointer algorithm that uses two pointers which move through the array (or sequence/linked list) at different speeds. This approach is quite useful when dealing with cyclic linked lists or arrays.
By moving at different speeds (say, in a cyclic linked list), the algorithm proves that the two pointers are bound to meet. The fast pointer should catch the slow pointer once both the pointers are in a cyclic loop.
How To Identify
- The problem will deal with a loop in a linked list or array
- When you need to know the position of a certain element or the overall length of the linked list
Questions
- Linked List Cycle (easy)
- Palindrome Linked List (medium)
- Cycle in a Circular Array (hard)Two Pointers Pattern
Two Pointers is a pattern where two pointers iterate through the data structure in tandem until one or both of the pointers hit a certain condition. Two Pointers is often useful when searching pairs in a sorted array or linked list; for example, when you have to compare each element of an array to its other elements.
How To Identify
- It will feature problems where you deal with sorted arrays (or Linked Lists) and need to find a set of elements that fulfill certain constraints
- The set of elements in the array is a pair, a triplet, or even a subarray
Questions
- Squaring a sorted array (easy)
- Triplets that sum to zero (medium)
- Comparing strings that contain backspaces (medium)
14 patterns to ace tech interviews 🔥
💎 Sliding Window
💎 2 Pointers or Iterators
💎 Fast and Slow Pointers or Iterators
💎 Merge Intervals
💎 Cyclic sort
💎 In-place reversal of linked list
💎 Tree BFS
💎 Tree DFS
💎 Two heaps
💎 Subsets
💎 Modified binary search
💎 Top K elements
💎 K-way merge
💎 Topological sort
𝐒𝐭𝐞𝐩-𝐛𝐲-𝐒𝐭𝐞𝐩 𝐠𝐮𝐢𝐝𝐞 𝐭𝐨 𝐢𝐦𝐩𝐫𝐨𝐯𝐞 𝐲𝐨𝐮𝐫 𝐃𝐒 𝐀𝐥𝐠𝐨 𝐬𝐤𝐢𝐥𝐥𝐬
📌 Focus on Quality not Quantity (Depth vs Breadth)
📖 Do not aim for solving tones of questions in a month, instead pick 100 quality questions, understand the logic, deduce patterns so that you can solve any question based on that technoque.
📌 Make a list of quality questions
📖 Research and make a list of quality questions in your excel sheet, start solving those and write those question which you were not able to solve.
📌 Master all the data structures with their implementations
📖 Already shared list on prev post, link in the comment section
📌 Repeat question
📖 Question you were not able to solve by your own, repeat them after few days, this is one of the underated step people dont follow.
📌 Make Note of Techniques and Patterns you observed in the solved questions
📖 Making fair notes for all the techniques algos and patterns will be very helpful, not only it will help you revise but isolating them will clear thepicture in your mind and you will be able to solve new questions based on that.
📌 Practice on NotePad/Paper
📖 Do not practice on IDE, Its you who want to learn and you are not testing the IDE's capability.
📌 Now Its time for covering Breadth
📖 Go on to any platform and start solving random problems as much as you can.
Dynamic Programming Patterns !!
Some standard Dynamic Programming solutions with different levels are given here. Do check below DP problems pattern-wise.
Longest Increasing Subsequence variants:
https://lnkd.in/gBM_sp78
https://lnkd.in/gX9Ahcq8
https://lnkd.in/gyqp7p-7
https://lnkd.in/gVncs-mU
https://lnkd.in/g8PsjvUc
https://lnkd.in/gPZjWxga
https://lnkd.in/gFz-UzBy
Partition Subset:
https://lnkd.in/gHKJxMbN
https://lnkd.in/gCYVAtdC
BitMasking:
https://lnkd.in/gNbrBE45
Longest Common Subsequence Variant:
https://lnkd.in/g-gK5cUm
https://lnkd.in/g8y-MF9K
https://lnkd.in/gcKcgDsy
https://lnkd.in/gTYPP8XX
Palindrome:
https://lnkd.in/gp62UKtj
https://lnkd.in/g9eSKc7P
Coin Change variant:
https://lnkd.in/gVwSnnmW
https://lnkd.in/gzsCcaxM
https://lnkd.in/gbE2Ztrc
https://lnkd.in/gnxGkJnw
https://lnkd.in/g89B4Sx5
Matrix multiplication variant:
https://lnkd.in/gfx6bgy9
https://lnkd.in/gSaPNNhQ
https://lnkd.in/gknKY6gC
Matrix/2D Array:
https://lnkd.in/gyZgY4HP
https://lnkd.in/gArgdbpu
https://lnkd.in/gJ9U4WuJ
https://lnkd.in/gkC8YzM5
https://lnkd.in/giyNEE7p
https://lnkd.in/gyur-_Bj
Hash + DP:
https://lnkd.in/gWNd8faP
https://lnkd.in/g3cZT64X
https://lnkd.in/gCDX8kps
https://lnkd.in/gctjnk6H
State machine:
https://lnkd.in/gTF3-c3E
https://lnkd.in/gyhSA6Qt
https://lnkd.in/g2ji_pEX
https://lnkd.in/ggT5fBNr
https://lnkd.in/g5avbqJH
https://lnkd.in/gNpyHDXk
Depth First Search + DP:
https://lnkd.in/gmazHDpy
https://lnkd.in/gnXBfmYU
Minimax DP:
https://lnkd.in/gzUPPYgX
https://lnkd.in/gqFKRvSe
Sliding Window Pattern
The Sliding Window pattern is used to perform a required operation on a specific window size of a given array or linked list, such as finding the longest subarray containing all 1s. Sliding Windows start from the 1st element and keep shifting right by one element and adjust the length of the window according to the problem that you are solving. In some cases, the window size remains constant and in other cases the sizes grows or shrinks.
How To Identify
- The problem input is a linear data structure such as a linked list, array, or string
- You’re asked to find the longest/shortest substring, subarray, or a desired value
Questions
- Maximum sum subarray of size ‘K’ (easy)
- Longest substring with ‘K’ distinct characters (medium)
- String anagrams (hard)