LEETCODE

Solutions, written up.

256 problems I have solved, most of them from the daily challenge. Each page explains the idea behind the solution, gives its complexity, and has the code (mostly Python and Java) that I tested before submitting. The source is on GitHub.

  1. 3841Palindromic Path Queries in a TreeArray · String · Divide and Conquer · Bit Manipulation · Tree · Depth-First Search · Binary Indexed Tree · Segment Treehard
  2. 3882Minimum XOR Path in a GridArray · Dynamic Programming · Bit Manipulation · Matrixmedium
  3. 3619Count Islands With Total Value Divisible by KArray · Depth-First Search · Breadth-First Search · Matrixmedium
  4. 1254Number of Closed IslandsArray · Depth-First Search · Breadth-First Search · Matrixmedium
  5. 2409Count Days Spent TogetherMath · Stringeasy
  6. 220Contains Duplicate IIIArray · Sliding Window · Sorting · Bucket Sorthard
  7. 3644Maximum K to Sort a PermutationArray · Bit Manipulationmedium
  8. 3942Minimum Operations to Sort a PermutationArraymedium
  9. 3863Minimum Operations to Sort a StringStringmedium
  10. 3886Sum of Sortable IntegersArray · Math · Sorting · Enumerationhard
  11. 2089Find Target Indices After Sorting ArrayArray · Binary Search · Sortingeasy
  12. 218The Skyline ProblemArray · Divide and Conquer · Heap (Priority Queue) · Segment Tree · Binary Indexed Treehard
  13. 1569Number of Ways to Reorder Array to Get Same BSTArray · Math · Divide and Conquer · Dynamic Programming · Tree · Memoization · Combinatorics · Binary Treehard
  14. 3551Minimum Swaps to Sort by Digit SumArray · Hash Table · Sortingmedium
  15. 2916Subarrays Distinct Element Sum of Squares IIArray · Hash Table · Binary Indexed Tree · Segment Treehard
  16. 2913Subarrays Distinct Element Sum of Squares IArray · Hash Tableeasy
  17. 214Shortest PalindromeString · String Matchinghard
  18. 3723Maximize Sum of Squares of DigitsMath · Greedymedium
  19. 3727Maximum Alternating Sum of SquaresArray · Greedy · Sortingmedium
  20. 2897Apply Operations on Array to Maximize Sum of SquaresArray · Hash Table · Greedy · Bit Manipulationhard
  21. 2778Sum of Squares of Special ElementsArray · Math · Enumerationeasy
  22. 212Word Search IIArray · String · Backtracking · Trie · Matrixhard
  23. 185Department Top Three SalariesDatabasehard
  24. 2333Minimum Sum of Squared DifferenceArray · Math · Binary Search · Sorting · Heap (Priority Queue) · Greedy · Countingmedium
  25. 1541Minimum Insertions to Balance a Parentheses StringString · Stack · Greedymedium
  26. 1021Remove Outermost ParenthesesString · Stackeasy
  27. 188Best Time to Buy and Sell Stock IVArray · Dynamic Programminghard
  28. 301Remove Invalid ParenthesesString · Backtracking · Breadth-First Searchhard
  29. 921Minimum Add to Make Parentheses ValidString · Stack · Greedymedium
  30. 856Score of ParenthesesString · Stackmedium
  31. 678Valid Parenthesis StringString · Dynamic Programming · Stack · Greedymedium
  32. 22Generate ParenthesesString · Dynamic Programming · Backtrackingmedium
  33. 149Max Points on a LineArray · Hash Table · Math · Geometryhard
  34. 20Valid ParenthesesString · Stackeasy
  35. 1111Maximum Nesting Depth of Two Valid Parentheses StringsString · Stack · Greedymedium
  36. 2267Check if There Is a Valid Parentheses String PathArray · Dynamic Programming · Matrix · Bit Manipulationhard
  37. 1614Maximum Nesting Depth of the ParenthesesString · Stackeasy
  38. 132Palindrome Partitioning IIString · Dynamic Programminghard
  39. 1807Evaluate the Bracket Pairs of a StringArray · Hash Table · Stringmedium
  40. 1190Reverse Substrings Between Each Pair of ParenthesesString · Stackmedium
  41. 1096Brace Expansion IIString · Backtracking · Stack · Breadth-First Searchhard
  42. 3550Smallest Index With Digit Sum Equal to IndexArray · Matheasy
  43. 126Word Ladder IIHash Table · String · Backtracking · Breadth-First Searchhard
  44. 1658Minimum Operations to Reduce X to ZeroArray · Hash Table · Binary Search · Sliding Window · Prefix Summedium
  45. 3525Find X Value of Array IIArray · Math · Segment Treehard
  46. 3524Find X Value of Array IArray · Math · Dynamic Programmingmedium
  47. 3498Reverse Degree of a StringString · Simulationeasy
  48. 123Best Time to Buy and Sell Stock IIIArray · Dynamic Programminghard
  49. 1401Circle and Rectangle OverlappingMath · Geometrymedium
  50. 1520Maximum Number of Non-Overlapping SubstringsString · Greedyhard
showing 50 of 256