ELEMENTS OF LEETCODE - Python solutions explained
These learning materials aim to provide explanations to basic algorithms in Python, including questions on Leetcode and elsewhere.
While the solutions are widely available through different sources, it is a greater challenge to find the logic behind the provided answers. This resource seeks to fill (or diminish) that gap.
Questions numbering is not the same as on Leetcode. To search for a Leetcode question use the “search docs” field. Enter the question number or title as it appears on Leetcode.
TABLE OF CONTENTS
- Knowledge base
- Part 1 (37-45)
- 37. Flatten a nested list
- 38. Reorder, evens first
- 39. (LC 75) Dutch national flag
- 40. (LC 66) Increment an arbitrary-precision integer
- 41. Multiply two arbitrary-precision integers
- 42. (LC 55) Jump Game (Advancing through an array)
- 43. (LC 26) Delete duplicates from a sorted array
- 44. (LC 121) Buy and sell a stock once
- 45. (LC 123) Buy and sell a stock twice
- Part 2 (46-55)
- 46. (LC 280) Computing an alternation
- 47. (LC 204) Enumerate all primes to n
- 48. Permute the elements of an array
- 49. (LC 31) Compute the next permutation
- 50. Sample offline data
- 51. Sample online data
- 52. (LC 384) Compute a random permutation
- 53. Generate nonuniform random numbers
- 54. (LC 36) Valid Sudoku
- 55. (LC 118) Compute rows in Pascal’s triangle
- Part 3 (56-65)
- 56. (LC 1) Two Sum
- 57. (LC 15) 3Sum
- 58. (LC 16) 3Sum Closest
- 59. (LC 989) Add to Array-Form of Integer
- 60. (LC 419) Battleships in a Board
- 61. (LC 121) Best Time to Buy and Sell Stock
- 62. (LC 309) Best Time to Buy and Sell Stock with Cooldown
- 63. (LC 122) Best Time to Buy and Sell Stock II
- 64. (LC 1014) Best Sightseeing Pair
- 65. (LC 605) Can Place Flowers
- Part 4 (66-75)
- 66. (LC 1109) Corporate Flight Bookings
- 67. (LC 697) Degree of an Array
- 68. (LC 498) Diagonal Traverse
- 69. (LC 888) Fair Candy Swap
- 70. (LC 442) Find All Duplicates in an Array
- 71. (LC 448) Find All Numbers Disappeared in an Array
- 72. (LC 724) Find Pivot Index
- 73. (LC 1275) Find Winner on a Tic Tac Toe Game
- 74. (LC 287) Find the Duplicate Number
- 75. (LC 412) Fizz Buzz
- Part 5 (76-85)
- 76. (LC 896) Monotonic Array
- 77. (LC 293) Flip Game
- 78. (LC 832) Flipping an Image
- 79. (LC 48) Rotate Image
- 80. (LC 334) Increasing Triplet Subsequence
- 81. (LC 56) Merge Intervals
- 82. (LC 57) Insert Interval
- 83. (LC 215) Kth Largest Element in an Array
- 84. (LC 747) Largest Number At Least Twice of Others
- 85. (LC 949) Largest Time for Given Digits
- Part 6 (86-95)
- 86. (LC 860) Lemonade Change
- 87. (LC 531) Lonely Pixel I
- 88. (LC 674) Longest Continuous Increasing Subsequence
- 89. (LC 128) Longest Consecutive Sequence
- 90. (LC 229) Majority Element II
- 91. (LC 643) Maximum Average Subarray I
- 92. (LC 624) Maximum Distance in Arrays
- 93. (LC 670) Maximum Swap
- 94. (LC 4) Median of Two Sorted Arrays
- 95. (LC 921) Minimum Add to Make Parentheses Valid
- Part 7 (96-105)
- 96. (LC 945) Minimum Increment to Make Array Unique
- 97. (LC 209) Minimum Size Subarray Sum
- 98. (LC 3) Longest Substring Without Repeating Characters
- 99. (LC 163) Missing Ranges
- 100. (LC 238) Product of Array Except Self
- 101. (LC 53) Maximum Subarray
- 102. (LC 152) Maximum Product Subarray
- 103. (LC 217) Contains Duplicate
- 104. (LC 33) Search in Rotated Sorted Array
- 105. (LC 11) Container With Most Water
- Extra (137)