DSA in Python
CtrlK
  • Personal Notes
  • Daily Coding Problem
    • Count Primes (Leetcode 204) (Sieve of Eratosthenes) (DCP
    • ***Serialize and Deserialize Binary Tree (Leetcode 297) (DCP 3)
  • Miscellaneous
    • ***Encode and Decode Strings
    • Shuffle an Array
  • Math
    • Maximum Product of Three Numbers (Leetcode 628)
    • Valid Square (Leetcode 593)
    • Minimum Area Rectangle (Leetcode 939)
    • The kth Factor of n (Leetcode 1492)
    • Reverse Integer (Leetcode 7)
    • Palindrome Number (Leetcode 9)
    • Excel Sheet Column Number (Leetcode 171)
    • Add Binary (Leetcode 67)
    • Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts (Leetcode 1465)
    • Roman to Integer (Leetcode 13)
  • Arrays
    • Two Sum (Leetcode 1) (DCP 1)
    • Two Sum II - Input Array Is Sorted (Leetcode 167)
    • Count pairs with given sum
    • Max Number of K Sum Pairs (Leetcode 1679)
    • Common Elements in 3 Sorted Arrays
    • Range Sum Query - Immutable (Leetcode 303)
    • Maximum Number of Balloons (Leetcode 1189)
    • Rearrange the Array
    • Swap and Maximise
    • K-diff Pairs in an Array (Leetcode 532)
    • 3Sum (Leetcode 15)
    • 3 Sum Closest (Leetcode 16)
    • Partition Array Into Three Parts With Equal Sum (Leetcode 1013)
    • Can Place Flowers (Leetcode 605)
    • Remove Element (Leetcode 27)
    • Invalid Transactions (Leetcode 1169)
    • 4 Sum (Leetcode 18)
    • Container with Most Water (Leetcode 11)
    • ***First Missing Positive (Leetcode 41) (DCP 4)
    • Product of Array Except Itself (Leetcode 238) (DCP 2)
    • Maximum Subarray (Kadane's Algo) (Leetcode 53)
    • Maximum Product Subarray (Leetcode 152)
    • Subarray with 0 sum
    • Next Permutation (Leetcode 31)
    • Longest Consecutive Sequence (Leetcode 128)
    • Best Time to Buy and Sell Stock (Leetcode 121)
    • Majority Element (Leetcode 169)
    • Majority Element II (Leetcode 229)
    • Missing Number (Leetcode 268)
    • Intersection of Two Arrays II (Leetcode 350)
    • Find the Duplicate Number (Leetcode 287)
    • Remove Duplicates from Sorted Array (Leetcode 26)
    • Pairs of Songs With Total Durations Divisible by 60 (Leetcode 1010)
    • Single Number (Leetcode 136)
    • Rotate Array (Leetcode 189)
    • Check if an Array is Sorted and Rotated (Leetcode 1752)
    • Subarray Sums Divisible by K (Leetcode 974)
    • Dutch National Flag Algorithm
      • Sort Colors (Leetcode 75)
      • Three Way Partitioning
      • Move Zeroes (Leetcode 283)
    • Running Sum of 1D Array (Leetcode 1480)
    • Best Time to Buy and Sell Stock (Leetcode 121)
    • Plus One (Leetcode 66)
    • Find Pivot Index (Leetcode 724)
    • Majority Element (Leetcode 169)
    • Find All Duplicates in an Array (Leetcode 442)
    • Concatenation of Array (Leetcode 1929)
    • Shortest Distance to a Character (Leetcode 821)
    • Pascal's Triangle (Leetcode 118)
    • Fibonacci Number (Leetcode 509)
    • Unique Email Addresses (Leetcode 929)
    • Isomorphic Strings (Leetcode 205)
    • Word Pattern (Leetcode 290)
    • Find All Numbers Disappeared in an Array (Leetcode 448)
    • Longest Valid Parentheses (Leetcode 32)
    • Minimum Time Difference (Leetcode 539)
    • Merge Sorted Array (Leetcode 88)
    • Insert Delete GetRandom O(1) (Leetcode 380)
  • Binary Search
    • Binary Search (Leetcode 704)
    • Find First and Last Position of Element in Sorted Array (Leetcode 34)
    • Number of Occurances
    • Find Minimum in Rotated Sorted Array (Leetcode 153)
    • Search in Rotated Sorted Array (Leetcode 33)
    • Sqrt(x) (Leetcode 69)
    • Ceil in a Sorted Array [Search Insert Position] (Leetcode 35)
    • Floor in a Sorted Array
    • Find Smallest Letter Greater Than Target (Leetcode 744)
    • Binary Search on Infinite Array [To be completed]
    • Find Peak Element (Leetcode 162)
    • Peak Index in a Mountain Array (Leetcde 852)
    • Single Element in a Sorted Array (Leetcode 540)
    • ***Median of Two Sorted Arrays (Leetcode 4)
    • Count Negative Numbers in a Sorted Matrix (Leetcode 1351)
    • ***Allocate Books
    • ***Painter's Partition Problem
    • ***Capacity To Ship Packages Within D Days (Leetcode 1011)
    • ***Koko Eating Bananas(Leetcode 875)
  • Stack
    • Evaluate Reverse Polish Notation (Leetcode 150)
    • Decode String (Leetcode 394)
    • Simplify Path (Leetcode 71)
    • Moving Average from Data Stream (Leetcode 642)
    • Valid Parentheses
    • Generate Parentheses (Leetcode 22)
    • Remove All Adjacent Duplicates In String (Leetcode 1047)
    • Remove All Adjacent Duplicates in String II (Leetcode 1209)
    • Backspace String Compare (Leetcode844)
    • NSL-NGR Pattern Questions
      • Nearest Smaller to Right
      • Nearest Smaller to Left
      • Next Greater to Right
      • Next Greater Element II
      • Daily Temperatures (Leetcode 739)
      • Stock Span Problem
      • Largest Rectangle in Histogram
      • Trapping Rain Water
      • Maximal Rectangle
    • **Sum of Subarray Minimums (Leetcode 907)
    • **Sum of Subarray Ranges (Leetcode 2104)
    • **Asteroid Collision (Leetcode 735)
    • **Remove K digits (Leetcode 402)
    • **The Celebrity Problem
    • *****Min Stack (Leetcode 155)
  • Heap
    • Kth Largest Element in an Array (Leetcode 215)
    • Top K Frequent Elements (Leetcode 347)
    • Kth Largest Element In A Stream
    • K Closest Points to Origin
    • Last Stone Weight
    • *** Find Median from Data Stream (Leetcode 295)
    • ***The Skyline Problem (Leetcode 218)
  • Intervals pattern
    • Merge Intervals (Leetcode 56)
    • Minimum Number of Arrows to Burst Balloons (Leetcode 452)
    • Non-overlapping Intervals (Leetcode 435)
    • N meetings in one room
    • Remove Covered Intervals (Leetcode 1288)
    • Meeting Rooms
    • Meeting Rooms II
    • Minimum Platforms
  • Linked Lists
    • Copy List with Random Pointer (Leetcode 138)
    • Merge K Sorted Lists (Leetcode 23)
  • Trees
    • Tree Traversals
      • Pre Order Traversal of a Binary Tree (Leetcode 144)
      • In Order Traversal of a Binary Tree (Leetcode 94)
      • Post Order Traversal of a Binary Tree (Leetcode 145)
      • Level Order Traversal of a Binary Tree (Leetcode 102)
      • Reverse Level Order Traversal of a Binary Tree (Leetcode 107)
    • Zig-Zag Level Order Traversal of a Binary Tree (Leetcode 103)
    • Maximum Depth of a Binary Tree (Leetcode 104)
    • Minimum Depth of Binary Tree (Leetcode 111)
    • Diameter of a Binary Tree (Leetcode 543)
    • Count number of nodes in a Binary Tree (Leetcode 222)
    • Sum of all nodes of a Binary Tree
    • Invert Binary Tree (Leetcode 226)
    • Minimum and Maximum of a Binary Tree
    • Average of Levels in a Binary Tree (Leetcode 637)
    • Deepest Leaves Sum (Leetcode 1302)
    • Find the corresponding node of a binary tree in the clone of that tree (Leetcode 1379)
    • Convert Sorted List to Binary Search Tree (Leetcode 109)
    • Lowest Common Ancestor of a Binary Tree (Leetcode 236)
    • Path Sum III (Leetcode 437)
    • Maximum Width of a Binary Tree (Leetcode 662)
    • Univalued Binary Tree (Leetcode 965)
    • Binary Tree Tilt (Leetcode 563)
    • Construct String from a Binary Tree (Leetcode 606)
    • Same Tree (Leetcode 100)
    • Count Nodes Equal to Average of Subtree (Leetcode 2265)
    • Flatten a Linked List (Leetcode 114)
    • Convert a Sorted Array into a Binary Search Tree(BST) (Leetcode 108)
    • Maximum Binary Tree (Leetcode 654)
    • Sum of Nodes with Even-Valued Grandparent (Leetcode 1315)
    • Leaf Similar Trees (Leetcode 872)
    • Balanced Binary Tree (Leetcode 110)
    • Path to a Given node
    • Binary Tree Paths (Leetcode 257)
    • Path Sum (Leetcode 112)
    • Sum of Root To Leaf Binary Numbers (Leetcode 1022)
    • Sum of Left Leaves (Leetcode 404)
    • Two Sum IV - Input is a BST (Leetcode 653) [Optimisation Required]
    • Kth Smallest Element in a BST (Leetcode 230) [Optimisation Required]
    • Subtree of Another Tree (Leetcode 572) [Optimisation required]
    • Validate Binary Search Tree(BST) (Leetcode 98)
    • Range Sum of BST (Leetcode 938)
    • Evaluate Boolean Binary Tree (Leetcode 2331)
    • Root Equals Sum of Children (Leetcode 2236)
    • Search in a Binary Search Tree(BST) (Leetcode 700)
    • Lowest Common Ancestor of a Binary Search Tree(BST) (Leetcode 235)
    • Find Bottom Left Tree Value (Leetcode 513)
    • Insert into a Binary Search Tree (Leetcode 701)
    • Symmetric Tree (Leetcode 101)
    • Merge Trees (Leetcode 617)
    • Binary Search Tree Iterator(Leetcode 173)
    • Balance a Binary Search Tree(BST) (Leetcode 1382)
    • Increasing Order Search Tree (Leetcode 897)
    • Minimum Distance Between BST Nodes (Leetcode 783)
    • Minimum Absolute Difference in BST (Leetcode 530)
    • Cousins in a Binary Tree (Leetcode 993)
    • Binary Search Tree to Greater Sum Tree (Leetcode 1038)
    • Count Good Nodes in Binary Tree (Leetcode 1448)
    • Recover Binary Search Tree (Leetcode 99)
    • Reverse Odd Levels of Binary Tree (Leetcode 2415)
    • Binary Tree Right Side View (Leetcode 199)
    • Top View of Binary Tree
    • Bottom View of Binary Tree
    • https://www.geeksforgeeks.org/print-nodes-distance-k-leaf-node/ [To be Done]
    • ***Find Leaves of Binary Tree
  • Tries
    • Implement Trie (Prefix Tree) (Leetcode 208)
    • Phone Directory [To be Done]
  • Graphs
    • BFS of Graph
    • DFS of Graph
    • Find cycle in undirected graph [To be done]
    • Find cycle in a directed graph [To be done]
    • Employee Importance (Leetcode 690)
    • Number of Provinces (Leetcode 547)
    • Number of Islands (Leetcode 200)
    • Number of Distinct Islands
    • Surrounded Regions(Leetcode 130)
    • Number of Enclaves (Leetcode 1020)
    • Rotting Oranges (Leetcode 994)
    • 01 Matrix (Leetcode 542)
    • Bi-Partite Graph
      • Is Graph Bipartite? (Leetcode 785) [BFS]
      • Is Graph Bipartite (Leetcode 785) [DFS] [To be done]
    • Word Ladder (Leetcode 127)
    • Word Ladder II (Leetcode 126) [To be done]
    • All Paths from Source to Target (Leetcode 797)
    • Restore the Array From Adjacent Pairs (Leetcode 1743)
    • Topological Sort
      • Kahn's Algorithm (Topological Sort using BFS)
      • Course Schedule I (Leetcode 207)
      • Course Schedule II (Leetcode 210)
      • Find Eventual Safe States (Leetcode 802)
      • Alien Dictionary
      • Shortest Path DAG [To be done]
      • Page 2
    • Dijkstra's Algorithm
      • Shortest Path in a DWAG [To be done]
      • Network Delay Time (Leetcode 743)
      • Path with Maximum Probability (Leetcode 1514)
      • Shortest Path in Binary Matrix (Leetcode 1091)
  • Sliding Window Pattern
    • Shortest Subarray with Sum at Least K (Leetcode 862) [To be done]
    • Replace the Substring for Balanced String (Leetcode 1234) [To be done]
    • Substring with Concatenation of All Words (Leetcode 30) [To be done]
    • Minimum Window Substring (Leetcode 76) [To be done]
    • Fixed Size Sliding Window Pattern
      • Max Sum Subarray of size K
      • Minimum Swaps and K Together
      • First negative integer in every window of size k
      • Substrings of Size Three with Distinct Characters (Leetcode 1876)
      • Find the K-Beauty of a Number (Leetcode 2269)
      • Maximum Average Subarray I (Leetcode 643)
      • Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold (Leetcode 1343)
      • Find All Anagrams in a String (Leetcode 438)
      • Permutation in String (Leetcode 567)
      • Minimum Recolors to Get K Consecutive Black Blocks (Leetcode 2379)
      • Maximum Points You Can Obtain from Cards (Leetcode 1423)
      • Minimum Difference Between Largest and Smallest Value in Three Moves (Leetcode 1509)
      • ***Sliding Window Maximum (Leetcode 239)
    • Variable Size Sliding Window Pattern
      • Minimum Size Subarray Sum (Leetcode 209)
      • Array Removals
      • Longest Substring Without Repeating Characters (Leetcode 3)
      • Longest K unique characters substring
      • ***Longest Repeating Character Replacement (Leetcode 424)
    • Maximum Consecutive Ones Pattern (ATMOST pattern)
      • ***Max Consecutive Ones (Leetcode 485)
      • ***Max Consecutive Ones II
      • ***Max Consecutive Ones III (Leetcode 1004)
      • ***Longest Subarray of 1's After Deleting One Element (Leetcode 1493)
      • Fruit Into Baskets (Leetcode 904)
      • Longest Substring with atmost two distinct characters
      • Longest Substring with At Most K Distinct Characters
    • Exactly K pattern
      • Binary Subarrays with Sum(Leetcode 930)
      • Subarrays with K Different Integers (Leetcode 992)
      • Number of Substrings Containing All Three Characters (Leetcode 1358)
    • Minimum Difference Between Highest and Lowest of K Scores (Leetcode 1984)
    • *** Longest Nice Substring (Leetcode 1763)
    • Contains Duplicate II (Leetcode 219)
    • Longest Substring with At Least K Repeating Characters (Leetcode 395)
    • Length of the Longest Alphabetical Continuous Substring(Leetcode 2414)
    • Count Number of Nice Subarrays (Leetcode 1248)
  • Greedy
    • Chocolate Problem
    • Job Sequencing Problem
    • Jump Game (Leetcode 55)
    • Box Stacking Problem [To be done]
    • *Minimum Platforms
    • Divide Intervals Into Minimum Number of Groups (Leetcode 2406)
  • DFS
    • Letter Combinations of a Phone Number (Leetcode 17)
    • Max Area of Island (Leetcode 695)
    • Island Perimeter (Leetcode 463)
  • BFS
    • Populating Next Right Pointers in Each Node (Leetcode 116)
  • Matrix
    • Rotate Image (Leetcode 48)
    • Flipping an Image (Leetcode 832)
    • Row with Max Ones
    • Game of Life (Leetcode 289)
    • Spiral Matrix (Leetcode 54)
    • Search a 2D Matrix (Leetcode 74)
    • Minimum Path Sum (Leetcode 64)
  • Two Pointers
    • Valid Palindrome II (Leetcode 680)
    • Optimal Partition of String (Leetcode 2405)
    • Sort Array By Parity (Leetcode 905)
    • Squares of a Sorted Array (Leetcode 977)
  • Strings
    • Add Strings (Leetcode 415)
    • Add Bold Tag In String
    • License Key Formatting (Leetcode 482)
    • Reverse Words in a String (Leetcode 151)
    • Repeated String Match (Leetcode 686)
    • Backspace String Compare (Leetcode 844)
    • Reverse Words in a String III (Leetcode 557)
    • Find First Palindromic String in the Array (Leetcode 2108)
    • Minimum Deletions to Make Character Frequencies Unique (Leetcode 1647)
    • Reverse Prefix of Word (Leetcode 2000)
    • Final Value of Variable After Performing Operations (Leetcode 2011)
    • Maximum Length of a Concatenated String with Unique Characters (Leetcode 1239)
    • Jewels and Stones (Leetcode 771)
    • Goal Parser Interpretation (Leetcode 1678)
    • Maximum Number of Words Found in Sentences (Leetcode 2114)
    • Minimum Remove to Make Valid Parentheses (Leetcode 1249)
    • *** Minimum Number of Moves to Make Palindrome (Leetcode 2193)
    • Number of Good Ways to Split a String (Leetcode 1525)
    • Defanging an IP Address (Leetcode 1108)
  • Recursion
    • Matrix Recursions
      • Flood Fill (Leetcode 733)
      • Word Search (Leetcode 79)
    • Subsets
    • Subsets II (Leetcode 90)
    • Combinations (Leetcode 77)
    • Combination Sum (Leetcode 39)
    • Combination Sum II (Leetcode 40)
    • Combination Sum III (Leetcode 216)
    • Permutations (Leetcode 46)
    • Permutations II (Leetcode 47)
    • Swap Nodes in Pairs (Leetcode 24)
    • Rat In A Maze
    • N Queens (Leetcode 51)
    • Pow(x, n) (Leetcode 50)
  • DP
    • 1D DP
      • Minimum Steps to One
      • Climbing Stairs (Leetcode 70)
      • Climb Stairs With Variable Jumps
      • Climb stairs with minimum moves
      • Frog Jump
      • Maximum Sum of Non-Adjacent Elements
      • House Robber
      • House Robber II
    • 2D DP (DP on Grids)
      • Ninja's Training
      • Unique Paths (Leetcode 62)
      • Unique Paths II (Leetcode 63)
      • Minimum Path Sum (Leetcode 64)
      • Triangle (Leetcode 120)
      • Minimum Falling Path Sum (Leetcode 931)
    • DP on Subsequences
      • 0 1 Knapsack
      • Subset Sum Problem
      • Last Stone Weight II (Leetcode 1049)
      • Count number of subsets with a given sum
      • Partition Equal Subset Sum (Leetcode 416)
      • Unbounded Knapsack
      • Rod Cutting
      • Coin Change 1 [Leetcode 322]
      • Coin Change II (Leetcode 518)
    • DP on Strings
      • Longest Common Subsequence (Leetcode 1143)
      • Shortest Common Supersequence
      • Print Longest Common Subsequence(LCS)
      • Print Shortest Common Supersequence (Leetcode 1092)
      • Longest Common Substring
      • Longest Palindromic Subsequence (Leetcode 516)
      • Minimum Insertion Steps to Make a String Palindrome (Leetcode 1312)
      • Delete Operation for Two Strings (Leetcode 583)
      • Distinct Subsequences
      • Edit Distance (Leetcode 72)
    • Arbitrary DP
      • Counting Bits (Leetcode 338)
      • N-th Tribonacci Number (Leetcode 1137)
    • DP on Stocks
      • Best Time to Buy and Sell Stock I
      • Best Time to Buy and Sell Stock II
  • Bit Manipulation
    • Number of 1 Bits (Leetcode 191)
    • Power of Two (Leetcode 231)
    • Longest Subarray With Maximum Bitwise AND (Leetcode 2419)
  • Prefix Sum
    • Subarray Sum Equals K (Leetcode 560)
  • Google Archives
    • Time needed to tell all employees [To be done]
    • Find Duplicate Trees (Leetcode 652) [To be done]
    • Maximum Profit in Job Scheduling (Leetcode 1235) [To be done]
    • Stream of Characters (Leetcode 1032) [To be done]
    • Maximum Number of Visible Points [To be done]
    • Design Snake Game [To be done]
    • Word Break II [To be done]
    • Minimise Cash Flow [To be done]
  • Amazon Archives
Powered by GitBook
On this page

Recursion

Matrix RecursionsSubsetsSubsets II (Leetcode 90)Combinations (Leetcode 77)Combination Sum (Leetcode 39)Combination Sum II (Leetcode 40)Combination Sum III (Leetcode 216)Permutations (Leetcode 46)Permutations II (Leetcode 47)Swap Nodes in Pairs (Leetcode 24)Rat In A MazeN Queens (Leetcode 51)Pow(x, n) (Leetcode 50)
PreviousDefanging an IP Address (Leetcode 1108)NextMatrix Recursions

Last updated 3 years ago