Master DSA and System Design with visual explanations. Learn more here: https://xitter.cf/t.co/jkSAEHWpOb

Joined June 2024
Tower of Hanoi - Recursion Visualization
14
233
13
2,102
387,504
10 Must-Know Time Complexity Patterns for Interviews: 1. ๐‡๐š๐ฌ๐ก ๐‹๐จ๐จ๐ค๐ฎ๐ฉ - ๐Ž(1) ๐š๐ฏ๐ž๐ซ๐š๐ ๐ž A lookup usually takes constant time, regardless of input size. In the worst case, it can degrade to O(n). 2. ๐‡๐š๐ฅ๐ฏ๐ข๐ง๐  ๐‹๐จ๐จ๐ฉ - ๐Ž(๐ฅ๐จ๐  ๐ง) The input size is divided by a constant factor in every step, such as in binary search. 3. ๐’๐ข๐ง๐ ๐ฅ๐ž ๐‹๐จ๐จ๐ฉ - ๐Ž(๐ง) Each element is processed once. 4. ๐’๐ž๐ช๐ฎ๐ž๐ง๐ญ๐ข๐š๐ฅ ๐‹๐จ๐จ๐ฉ๐ฌ - ๐Ž(๐ง + ๐ฆ) You iterate over two separate inputs one after another, not with one loop nested inside the other. 5. ๐‹๐จ๐จ๐ฉ + ๐๐ข๐ง๐š๐ซ๐ฒ ๐’๐ž๐š๐ซ๐œ๐ก - ๐Ž(๐ง ๐ฅ๐จ๐  ๐ง) A loop runs n times, and each iteration performs O(log n) work. 6. ๐ƒ๐ข๐ฏ๐ข๐๐ž & ๐‚๐จ๐ง๐ช๐ฎ๐ž๐ซ - ๐Ž(๐ง ๐ฅ๐จ๐  ๐ง) The problem is divided across roughly log n levels, with O(n) total work at each level. Merge sort is a common example. 7. ๐๐ž๐ฌ๐ญ๐ž๐ ๐‹๐จ๐จ๐ฉ๐ฌ - ๐Ž(๐งยฒ) For every element, you iterate over all elements again. 8. ๐“๐ซ๐ข๐š๐ง๐ ๐ฎ๐ฅ๐š๐ซ ๐‹๐จ๐จ๐ฉ - ๐Ž(๐งยฒ) The inner loop performs fewer iterations each time, but the total is still roughly n(n โˆ’ 1) / 2, which is quadratic. 9. ๐๐ซ๐š๐ง๐œ๐ก๐ข๐ง๐  ๐‘๐ž๐œ๐ฎ๐ซ๐ฌ๐ข๐จ๐ง - ๐„๐ฑ๐ฉ๐จ๐ง๐ž๐ง๐ญ๐ข๐š๐ฅ ๐“๐ข๐ฆ๐ž When each recursive call creates multiple new calls, the work can grow exponentially. 10. ๐๐ž๐ซ๐ฆ๐ฎ๐ญ๐š๐ญ๐ข๐จ๐ง๐ฌ - ๐Ž(๐ง!) There are n! possible orderings, and producing or copying each complete permutation can take O(n) time. โ™ป๏ธ Repost to help others in your network.
1
20
105
3,093
14 Must-Know Data Structures for Coding Interviews: 1. Array 2. Queue 3. Deque 4. Matrix 5. Stack 6. Binary Tree 7. Linked List 8. Doubly Linked List 9. HashMap 10. Binary Search Tree (BST) 11. Heap (Priority Queue) 12. Trie 13. Graph 14. Union Find โ™ป๏ธ Repost to help others in your network
1
95
2
418
10,832
7 Must-Know Big-O Complexities for Interviews: 1. ๐Ž(1) - ๐‚๐จ๐ง๐ฌ๐ญ๐š๐ง๐ญ ๐ญ๐ข๐ฆ๐ž - The runtime doesn't change regardless of the input size. - Example: Accessing an element in an array by its index. 2. ๐Ž(๐ฅ๐จ๐  ๐ง) - ๐‹๐จ๐ ๐š๐ซ๐ข๐ญ๐ก๐ฆ๐ข๐œ ๐ญ๐ข๐ฆ๐ž - The runtime grows slowly as the input size increases. Typically seen in algorithms that divide the problem in half with each step. - Example: Binary search in a sorted array. 3. ๐Ž(๐ง) - ๐‹๐ข๐ง๐ž๐š๐ซ ๐ญ๐ข๐ฆ๐ž - The runtime grows linearly with the input size. - Example: Finding an element in an array by iterating through each element. 4. ๐Ž(๐ง ๐ฅ๐จ๐  ๐ง) - ๐‹๐ข๐ง๐ž๐š๐ซ๐ข๐ญ๐ก๐ฆ๐ข๐œ ๐ญ๐ข๐ฆ๐ž - The runtime grows slightly faster than linear time. It involves a logarithmic number of operations for each element in the input. - Example: Sorting an array using quick sort or merge sort. 5. ๐Ž(๐ง^2) - ๐๐ฎ๐š๐๐ซ๐š๐ญ๐ข๐œ ๐ญ๐ข๐ฆ๐ž - The runtime grows proportionally to the square of the input size. - Example: Bubble sort algorithm which compares and potentially swaps every pair of elements. 6. ๐Ž(2^๐ง) - ๐„๐ฑ๐ฉ๐จ๐ง๐ž๐ง๐ญ๐ข๐š๐ฅ ๐ญ๐ข๐ฆ๐ž - The runtime doubles with each addition to the input. These algorithms become impractical for larger input sizes. - Example: Generating all subsets of a set. 7. ๐Ž(๐ง!) - ๐…๐š๐œ๐ญ๐จ๐ซ๐ข๐š๐ฅ ๐ญ๐ข๐ฆ๐ž - Runtime is proportional to the factorial of the input size. - Example: Generating all permutations of a set. โ™ป๏ธ Repost to help others learn this
5
32
1,673
10 Must-Know Graph Algorithms for Coding Interviews: 1. DFS (Depth-First Search) 2. BFS (Breadth-First Search) 3. Topological Sort 4. Union Find (Disjoint Set) 5. Cycle Detection 6. Connected Components 7. Bipartite Check 8. Flood Fill 9. Minimum Spanning Tree 10. Shortest Path (Dijkstra) โ™ป๏ธ Repost to help others in your network
6
128
3
645
19,665
Basic OOP Concepts Explained with Clear Examples: 1. ๐„๐ง๐œ๐š๐ฉ๐ฌ๐ฎ๐ฅ๐š๐ญ๐ข๐จ๐ง Hide internal data behind public methods. - Example: A BankAccount class keeps balance and pin private. The only way to interact with it is through deposit() and getBalance(). 2. ๐€๐›๐ฌ๐ญ๐ซ๐š๐œ๐ญ๐ข๐จ๐ง Expose a simple interface, hide the complexity behind it. - Example: An EmailService class gives you sendEmail(to, body). Internally, it handles SMTP connections, authentication, and retry logic. The caller doesn't need to know any of that. They just call one method and it works. 3. ๐ˆ๐ง๐ก๐ž๐ซ๐ข๐ญ๐š๐ง๐œ๐ž Let child classes reuse and override behavior from a parent class. - Example: An Animal class defines speak(). Dog extends it and returns "Woof!", Cat extends it and returns "Meow!". Shared logic lives in one place, and each subclass customizes what it needs. 4. ๐๐จ๐ฅ๐ฒ๐ฆ๐จ๐ซ๐ฉ๐ก๐ข๐ฌ๐ฆ Write code that works with multiple types through a common interface. - Example: Define a Shape interface with a draw() method. Now Circle, Rectangle, and Triangle each implement draw() their own way. A single drawShape(Shape s) method works with all of them. โ™ป๏ธ Repost to help others learn this
8
199
1
1,007
35,751
AlgoMaster.io retweeted
๐‡๐จ๐ฐ ๐ญ๐จ ๐…๐ข๐ง๐ ๐š ๐‚๐ฒ๐œ๐ฅ๐ž ๐ข๐ง ๐š ๐‹๐ข๐ง๐ค๐ž๐ ๐‹๐ข๐ฌ๐ญ Use Floydโ€™s Cycle Detection Algorithm, also known as the slow and fast pointer technique. Start two pointers at the head: - slow moves one step at a time - fast moves two steps at a time If the linked list has no cycle, fast will eventually reach the end. If there is a cycle, fast will eventually catch up with slow inside the loop. Why does this work? Think of two runners on a circular track. If one runs faster than the other, they are guaranteed to meet eventually. Time Complexity: O(n) Space Complexity: O(1)
2
28
180
6,759
๐‡๐จ๐ฐ ๐ญ๐จ ๐…๐ข๐ง๐ ๐š ๐‚๐ฒ๐œ๐ฅ๐ž ๐ข๐ง ๐š ๐‹๐ข๐ง๐ค๐ž๐ ๐‹๐ข๐ฌ๐ญ Use Floydโ€™s Cycle Detection Algorithm, also known as the slow and fast pointer technique. Start two pointers at the head: - slow moves one step at a time - fast moves two steps at a time If the linked list has no cycle, fast will eventually reach the end. If there is a cycle, fast will eventually catch up with slow inside the loop. Why does this work? Think of two runners on a circular track. If one runs faster than the other, they are guaranteed to meet eventually. Time Complexity: O(n) Space Complexity: O(1)
2
28
180
6,759
AlgoMaster.io retweeted
Tower of Hanoi - Recursion Visualization
14
233
13
2,102
387,504
15 Must-Know Software Design Patterns: 1. Singleton 2. Factory Method 3. Builder 4. Adapter 5. Decorator 6. Facade 7. Proxy 8. Composite 9. Observer 10. Strategy 11. Command 12. Iterator 13. State 14. Template Method 15. Chain of Responsibility โ™ป๏ธ Repost to help others in your network
9
138
2
567
17,810
20 must-know DSA patterns for coding interviews: 1. Prefix Sum 2. Two Pointers 3. Sliding Window 4. Fast & Slow Pointers 5. LinkedList In-place Reversal 6. Frequency Counting 7. Monotonic Stack 8. Bit Manipulation 9. Top โ€˜Kโ€™ Elements 10. Overlapping Intervals 11. Binary Search Variants 12. Binary Tree Traversal 13. Depth-First Search (DFS) 14. Breadth-First Search (BFS) 15. Shortest Path 16. Matrix Traversal 17. Backtracking 18. Prefix Search (Trie) 19. Greedy 20. Dynamic Programming Patterns โ™ป๏ธ Repost to help others master coding interviews
4
63
3
345
11,714
7 Must-Know Big-O Complexities for Coding Interviews: 1. ๐Ž(1) - ๐‚๐จ๐ง๐ฌ๐ญ๐š๐ง๐ญ ๐ญ๐ข๐ฆ๐ž - The runtime doesn't change regardless of the input size. - Example: Accessing an element in an array by its index. 2. ๐Ž(๐ฅ๐จ๐  ๐ง) - ๐‹๐จ๐ ๐š๐ซ๐ข๐ญ๐ก๐ฆ๐ข๐œ ๐ญ๐ข๐ฆ๐ž - The runtime grows slowly as the input size increases. Typically seen in algorithms that divide the problem in half with each step. - Example: Binary search in a sorted array. 3. ๐Ž(๐ง) - ๐‹๐ข๐ง๐ž๐š๐ซ ๐ญ๐ข๐ฆ๐ž - The runtime grows linearly with the input size. - Example: Finding an element in an array by iterating through each element. 4. ๐Ž(๐ง ๐ฅ๐จ๐  ๐ง) - ๐‹๐ข๐ง๐ž๐š๐ซ๐ข๐ญ๐ก๐ฆ๐ข๐œ ๐ญ๐ข๐ฆ๐ž - The runtime grows slightly faster than linear time. It involves a logarithmic number of operations for each element in the input. - Example: Sorting an array using quick sort or merge sort. 5. ๐Ž(๐ง^2) - ๐๐ฎ๐š๐๐ซ๐š๐ญ๐ข๐œ ๐ญ๐ข๐ฆ๐ž - The runtime grows proportionally to the square of the input size. - Example: Bubble sort algorithm which compares and potentially swaps every pair of elements. 6. ๐Ž(2^๐ง) - ๐„๐ฑ๐ฉ๐จ๐ง๐ž๐ง๐ญ๐ข๐š๐ฅ ๐ญ๐ข๐ฆ๐ž - The runtime doubles with each addition to the input. These algorithms become impractical for larger input sizes. - Example: Generating all subsets of a set. 7. ๐Ž(๐ง!) - ๐…๐š๐œ๐ญ๐จ๐ซ๐ข๐š๐ฅ ๐ญ๐ข๐ฆ๐ž - Runtime is proportional to the factorial of the input size. - Example: Generating all permutations of a set. โ™ป๏ธ Repost to help others learn this
5
147
6
762
36,540
๐‡๐จ๐ฐ ๐Œ๐ž๐ซ๐ ๐ž ๐’๐จ๐ซ๐ญ ๐–๐จ๐ซ๐ค๐ฌ Merge Sort is a classic Divide & Conquer algorithm. Hereโ€™s the idea: - Divide โ†’ Split the array into two halves - Conquer โ†’ Recursively sort both halves - Combine โ†’ Merge the sorted halves into one sorted array The magic lies in the merge step, where two sorted arrays are combined efficiently in linear time. Time Complexity: O(n log n) (always) Quick example: [5, 2, 4, 1] โ†’ [5, 2] + [4, 1] โ†’ [2, 5] + [1, 4] โ†’ [1, 2, 4, 5] โ™ป๏ธ Repost to help others in your network
6
50
2,549
How Bubble Sort Works
8
60
8,164
14 must-know Data Structures for coding interviews: 1. Array 2. Queue 3. Deque 4. Matrix 5. Stack 6. Binary Tree 7. Linked List 8. Doubly Linked List 9. HashMap 10. Binary Search Tree (BST) 11. Heap (Priority Queue) 12. Trie 13. Graph 14. Union Find โ™ป๏ธ Repost to help others in your network
8
344
11
1,786
70,005
10 must-know Array patterns for coding interviews: 1. Two Pointers 2. Sliding Window 3. Prefix Sum 4. Kadane's Algorithm 5. Binary Search 6. Cyclic Sort 7. Merge Intervals 8. Monotonic Stack 9. Hash Map Lookup 10. Sorting + Greedy โ™ป๏ธ Repost to help others in your network
8
44
1
235
9,181
If you want to master dynamic programming for coding interviews, learn these 20 patterns: 1. Fibonacci Numbers 2. 0/1 Knapsack 3. Unbounded Knapsack 4. Longest Common Subsequence 5. Longest Increasing Subsequence 6. Palindromic Subsequence 7. Matrix Chain 8. Edit Distance 9. Coin Change 10. Kadane's Algorithm 11. Grid Paths 12. Subset Sum 13. Rod Cutting 14. Climbing Stairs 15. House Robber 16. Interval DP 17. State Machine DP 18. Tree DP 19. Bitmask DP 20. Digit DP โ™ป๏ธ Repost to help others in your network
4
64
1
331
11,230