pauldevos / leetcode-solutions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Easy

# Problem Solution Time comp. Space com. Notes
1 Two Sum O(n) O(n) Array, Hash Table
7 Reverse Integer O(log n) O(1) Math, Array
9 Palindrome Number O(log n) O(1) Math, Array
13 Roman to Integer O(n) O(1) Math, String, Hash Table
14 Longest Common Prefix O(n * min(s)) O(1) String, Array
20 Valid Parentheses O(n) O(n) String, Stack
21 Merge Two Sorted Lists O(n+m) O(1) Linked List
26 Remove Duplicates from Sorted Array JS O(n) O(1) Array, Two Pointers
27 Remove Element JS O(n) O(1) Array, Two Pointers
28 Implement strStr() JS O(n*m) O(n) String, Two Pointers
35 Search Insert Position O(log n) O(1) Array, Binary Search
38 Count and Say JS ? ? String
53 Maximum Subarray O(n) O(1) Array, Dynamic Programming, Divide and Conquer
58 Length of Last Word JS O(n) O(1) String
66 Plus One JS O(n) O(1) Array
67 Add Binary O(Max(n,m)) O(Max(n,m))_ Math, String
69 Sqrt(x) JS O(log n) O(1) Math, Binary Search
70 Climbing Stairs JS O(n) O(1) Dynamic Programming
83 Remove Duplicates from Sorted List JS O(n) O(1) Linked List
88 Merge Sorted Array JS O(n+m) O(1) Array, Two Pointers
100 Same Tree JS O(n) O(1) Tree, Depth-first Search
101 Symmetric Tree JS O(n) O(n) Tree, DFS, BFS
102 Binary Tree Level Order Traversal O(n) O(n) Tree, BFS
104 Maximum Depth of Binary Tree JS O(n) O(n) Tree, DFS
112 Path Sum O(n) O(n) Tree, DFS
118 Pascal's Triangle JS O(n^2) O(n^2) Array
119 Pascal's Triangle II O(n^2) O(n) Array
121 Best Time to Buy and Sell Stock O(n) O(1) Array, Dynamic Programming
171 Excel Sheet Column Number O(n) O(1) Math
242 Valid Anagram O(n) O(1) Hash Table, Sort
303 Range Sum Query - Immutable O(n) O(n) Dynamic Programming
349 Intersection of Two Arrays O(n) O(n) Hash Table, Two Pointers, Binary Search, Sort
733 Flood Fill O(n) O(n) BFS, DFS
917 Reverse Only Letter O(n) O(1) String
1184 Distance Between Bus Stops O(n) O(1) Array
1189 Maximum Number of Balloons O(n) O(1) Hash Table, String
1200 Minimum absolute Difference O(n * log n) O(n) Array
1208 Get Equal Substrings within Budget O(n) O(1) Array, Sliding Window
1209 Remove All Adjacent Duplicates in String II O(n) O(n) Array, Stack, Two Pointers

Medium

# Problem Solution Time comp. Space com. Notes
2 Add Two Numbers O(n) O(n) Linked List, Math
3 Longest Substring without Repeating Chars O(n) O(min(n,m)) Hash Table, Two Pointers, String, Sliding Window
8 String to Integer (atoi) O(n) O(1) Math, String
11 Container with Most Water O(n) O(1) Array, Two Pointers
15 3Sum JS O(n^2) O(n^2) Array, Two Pointers
17 Letter Combinations of Phone Number
19 Remove Nth Node from End of List O(n) O(1) Linked List, Two Pointers
24 Swap Nodes in Pairs O(n) O(1) Linked List
31 Next Permutation O(n) O(1) Array
34 Find First and Last Position of Element in Sorted Array O(log n) O(1) Array, Binary Search
36 Valid Sudoku JS O(1) O(1) Hash Table
48 Rotate Image O(n) O(1) Array
54 Spiral Matrix O(n) O(n) Array
59 Spiral Matrix II O(n) O(n) Array
64 Minimum Path Sum O(n) O(1) Array, Dynamic Programming
74 Search a 2D Matrix O(log(m) + log(n)) O(1) Array, Binary Search
75 Sort Colors O(n) O(1) Array, Two Pointers, Sort
113 Path Sum II O(n) O(depth*2^depth) Tree, DFS
120 Triangle O(n) O(log n) Array, Dynamic Programming
129 Sum Root to Leaf Numbers O(n) O(n) Tree, DFS
304 Range Sum Query 2D - Immutable Dynamic Programming
319 Bulb Switcher O(1) O(1) Math, Brainteaser
438 Find All Anagrams O(n) O(1) Hash Table, Sliding Window, Two Pointers
486 Predict the Winner ? ? Dynamic Programming, Minmax
508 Most Frequent Subtree Sum O(n) O(n) Hash Table, Tree, DFS
567 Permutation in String O(n) O(1) Two Pointers, Sliding Window, Hash Table
622 Design Circular Queue N/A N/A Design, Queue
865 Smallest Subtree with all the Deepest Nodes O(n) O(n) Tree, DFS
988 Smallest String Starting from Leaf O(n * log n) O(n) Tree, DFS
1080 Insufficient Nodes in Root to Leaf Paths O(n) O(n) Tree, DFS
1219 Path with Maximum Gold O(nm3^(m*n)) O(n) DFS, Backtracking

Hard

# Problem Solution Time comp. Space com. Notes
4 Median of Two Sorted Arrays JS O(log min(n, m)) O(1) Array, Binary Search, Divide and Conquer
10 Regular Expression Matching JS O(n * m) O(n * m) String, Dynamic Programming, Backtracking
23 Merge k Sorted Lists Linked List, Divide and Conquer, Heap

Newly added problem solutions

Due to time concerns, I only add a small link to newly added problems. I can either do that or skip it altogether.

404. Sum of Left Leaves

python solution

go solution

https://leetcode.com/problems/sum-of-left-leaves/

1260. Shift 2D Grid

python solution

go solution

ts solution]

https://leetcode.com/problems/shift-2d-grid/

382. Linked List Random Node

python solution

go solution

https://leetcode.com/problems/linked-list-random-node/

441. Arranging Coins

python solution

go solution

https://leetcode.com/problems/arranging-coins/

260. Single Number III

python solution

go solution

https://leetcode.com/problems/single-number-iii/

1275. Find Winner on a Tic Tac Toe Game

python solution

go solution

https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game/

96. Unique Binary Search Trees

python solution

go solution

https://leetcode.com/problems/unique-binary-search-trees/

43. Multiply Strings

python solution

go solution

https://leetcode.com/problems/multiply-strings/

437. Path Sum III

python solution

go solution

https://leetcode.com/problems/path-sum-iii/

1178. Number of Valid Words for Each Puzzle

python solution

go solution

https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/

1002. Find Common Characters

python solution

go solution

https://leetcode.com/problems/find-common-characters/

122. Best Time to Buy and Sell Stock II

python solution

go solution

https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/

1413. Minimum Value to Get Positive Step by Step Sum

python Solution

go Solution

https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/

  1. Minimum Cost to Make at Least One Valid Path in a Grid python solution

go solution

https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/

203. Remove Linked List Elements

python solution

go solution

https://leetcode.com/problems/remove-linked-list-elements/

739. Daily Temperatures

python solution

go solution

https://leetcode.com/problems/daily-temperatures/

2065. Maximum Path Quality of a Graph

python solution

go solution

https://leetcode.com/problems/maximum-path-quality-of-a-graph/

1286. Iterator for Combination

python solution

go solution

https://leetcode.com/problems/iterator-for-combination

368. Largest Divisible Subset

python solution

go solution

https://leetcode.com/problems/largest-divisible-subset/

668. Kth Smallest Number in Multiplication Table

python solution

go solution

https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/

62. Unique Paths

python solution

go solution

https://leetcode.com/problems/unique-paths/

448. Find All Numbers Disappeared in an Array

python solution

go solution

https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array

461. Hamming Distance

python solution

go solution

https://leetcode.com/problems/hamming-distance/

61. Rotate List

python solution

go solution

https://leetcode.com/problems/rotate-list/

324. Wiggle Sort II

python solution

go solution

https://leetcode.com/problems/wiggle-sort-ii/

540. Single Element in a Sorted Array

python solution

go solution

https://leetcode.com/problems/single-element-in-a-sorted-array/

51. N-Queens

python solution

go solution

https://leetcode.com/problems/n-queens/

106. Construct Binary Tree from Inorder and Postorder Traversal

python solution

go solution

https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal

450. Delete Node in a BST

python solution

go solution

https://leetcode.com/problems/delete-node-in-a-bst/

952. Largest Component Size by Common Factor

python solution

go solution

https://leetcode.com/problems/largest-component-size-by-common-factor/

986. Interval List Intersections

python solution

go solution

https://leetcode.com/problems/interval-list-intersections/

238. Product of Array Except Self

python solution

go solution

https://leetcode.com/problems/product-of-array-except-self/

315. Count of Smaller Numbers After Self

python solution

go solution

https://leetcode.com/problems/count-of-smaller-numbers-after-self/

327. Count of Range Sum

python solution

go solution

https://leetcode.com/problems/count-of-range-sum/

552. Student Attendance Record II

python solution

go solution

https://leetcode.com/problems/student-attendance-record-ii/

797. All Paths From Source to Target

python solution

go solution

https://leetcode.com/problems/all-paths-from-source-to-target/

721. Accounts Merge

python solution

go solution

https://leetcode.com/problems/accounts-merge/

85. Maximal Rectangle

python solution

go solution

https://leetcode.com/problems/maximal-rectangle/

198. House Robber

python solution

go solution

https://leetcode.com/problems/house-robber/

328. Odd Even Linked List

python solution

go solution

https://leetcode.com/problems/odd-even-linked-list/

152. Maximum Product Subarray

python solution

go solution

https://leetcode.com/problems/maximum-product-subarray/

1032. Stream of Characters

python solution

go solution

https://leetcode.com/problems/stream-of-characters/

337. House Robber III

python solution

go solution

https://leetcode.com/problems/house-robber-iii/

1217. Minimum Cost to Move Chips to The Same Position

python solution

go solution

https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position/

1290. Convert Binary Number in a Linked List to Integer

python solution

go solution

https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/

563. Binary Tree Tilt

python solution

go solution

https://leetcode.com/problems/binary-tree-tilt/

1306. Jump Game III

python solution

go solution

https://leetcode.com/problems/jump-game-iii/

790. Domino and Tromino Tiling

python solution

go solution

https://leetcode.com/problems/domino-and-tromino-tiling/

878. Nth Magical Number

python solution

go solution

https://leetcode.com/problems/nth-magical-number/

416. Partition Equal Subset Sum

python solution

go solution

https://leetcode.com/problems/partition-equal-subset-sum/

1446. Consecutive Characters

python solution

go solution

https://leetcode.com/problems/consecutive-characters/submissions/

938 Range Sum of BST

python solution

go solution

https://leetcode.com/problems/range-sum-of-bst/submissions/

147. Insertion Sort List

python solution

go solution

https://leetcode.com/problems/insertion-sort-list/

310. Minimum Height Trees

python solution

go solution

https://leetcode.com/problems/minimum-height-trees/

221. Maximal Square

python solution

go solution

https://leetcode.com/problems/maximal-square/

902. Numbers At Most N Given Digit Set

python solution

https://leetcode.com/problems/numbers-at-most-n-given-digit-set/

231. Power of Two

python solution

go solution

https://leetcode.com/problems/power-of-two/submissions/

143. Reorder List

python solution

go solution

https://leetcode.com/problems/reorder-list/

210. Course Schedule II

python solution

go solution

https://leetcode.com/problems/course-schedule-ii/

56. Merge Intervals

python solution

go solution

https://leetcode.com/problems/merge-intervals/

973. K Closest Points to Origin

python solution

https://leetcode.com/problems/k-closest-points-to-origin/

476. Number Complement

python solution

https://leetcode.com/problems/number-complement/

1041. Robot Bounded In Circle

python solution

go solution

https://leetcode.com/problems/robot-bounded-in-circle/

1022. Sum of Root To Leaf Binary Numbers

python solution

go solution

https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/

1463. Cherry Pickup II

python solution

go solution

https://leetcode.com/problems/cherry-pickup-ii/

701. Insert into a Binary Search Tree

python solution

go solution

https://leetcode.com/problems/insert-into-a-binary-search-tree/

452. Minimum Number of Arrows to Burst Balloons

python solution

go solution

https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/

2134. Minimum Swaps to Group All 1's Together II

python solution

go solution

https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/

2135. Count Words Obtained After Adding a Letter

python solution

go solution

https://leetcode.com/problems/count-words-obtained-after-adding-a-letter/

344. Reverse String

python solution

go solution

js solution

https://leetcode.com/problems/reverse-string/

557. Reverse Words in a String III

python solution

go solution

https://leetcode.com/problems/reverse-words-in-a-string-iii/

1345. Jump Game IV

python soluton

go solution

https://leetcode.com/problems/jump-game-iv/

876. Middle of the Linked List

python solution

go solution

https://leetcode.com/problems/middle-of-the-linked-list/

849. Maximize Distance to Closest Person

python solution

go solution

https://leetcode.com/problems/maximize-distance-to-closest-person/

290. Word Pattern

python solution

go solution

https://leetcode.com/problems/word-pattern/

695. Max Area of Island

python solution

go solution

https://leetcode.com/problems/max-area-of-island/

605. Can Place Flowers

python solution

go solution

https://leetcode.com/problems/can-place-flowers/

617. Merge Two Binary Trees

python solution

go solution

https://leetcode.com/problems/merge-two-binary-trees/

116. Populating Next Right Pointers in Each Node

python solution

go solution

https://leetcode.com/problems/populating-next-right-pointers-in-each-node/

142. Linked List Cycle II

python solution

go solution

https://leetcode.com/problems/linked-list-cycle-ii/

875. Koko Eating Bananas

python solution

go solution

https://leetcode.com/problems/koko-eating-bananas/

206. Reverse Linked List

python solution

go solution

https://leetcode.com/problems/reverse-linked-list/

77. Combinations

python solution

go solution

https://leetcode.com/problems/combinations/

134. Gas Station

python solution

go solution

https://leetcode.com/problems/gas-station/

1510. Stone Game IV

python solution

go solution

https://leetcode.com/problems/stone-game-iv/

1291. Sequential Digits

python solution

go solution

https://leetcode.com/problems/sequential-digits/

520. Detect Capital

python solution

go solution

https://leetcode.com/problems/detect-capital/

941. Valid Mountain Array

python solution

go solution

https://leetcode.com/problems/valid-mountain-array/

33. Search in Rotated Sorted Array

python solution

go solution

https://leetcode.com/problems/search-in-rotated-sorted-array/

1305. All Elements in Two Binary Search Trees

python solution

https://leetcode.com/problems/all-elements-in-two-binary-search-trees/

153. Find Minimum in Rotated Sorted Array

python solution

go solution

https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/

421. Maximum XOR of Two Numbers in an Array

python solution

https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/

82. Remove Duplicates from Sorted List II

python solution

go solution

https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/

211. Design Add and Search Words Data Structure

python solution

https://leetcode.com/problems/design-add-and-search-words-data-structure/

844. Backspace String Compare

python solution

go solution

https://leetcode.com/problems/backspace-string-compare/

84. Largest Rectangle in Histogram

python solution

https://leetcode.com/problems/largest-rectangle-in-histogram/

189. Rotate Array

python solution

go solution

https://leetcode.com/problems/rotate-array/

1672. Richest Customer Wealth

python solution

go solution

https://leetcode.com/problems/richest-customer-wealth/

454. 4Sum II

python solution

go solution

https://leetcode.com/problems/4sum-ii/

525. Contiguous Array

python solution

https://leetcode.com/problems/contiguous-array/

80. Remove Duplicates from Sorted Array II

python solution

go solution

https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/

389. Find the Difference

python solution

https://leetcode.com/problems/find-the-difference/

258. Add Digits

python solution

go solution

https://leetcode.com/problems/add-digits/

532. K-diff Pairs in an Array

python solution

https://leetcode.com/problems/k-diff-pairs-in-an-array/

560. Subarray Sum Equals K

python solution

go solution

https://leetcode.com/problems/subarray-sum-equals-k/

138. Copy List with Random Pointer

python solution

go solution

ts solution

https://leetcode.com/problems/copy-list-with-random-pointer/

71. Simplify Path

python solution

go solution

js solution

https://leetcode.com/problems/simplify-path/

946. Validate Stack Sequences

python solution

https://leetcode.com/problems/validate-stack-sequences/

316. Remove Duplicate Letters

python solution

https://leetcode.com/problems/remove-duplicate-letters/

991. Broken Calculator

python solution

https://leetcode.com/problems/broken-calculator/

881. Boats to Save People

python solution

https://leetcode.com/problems/boats-to-save-people/

1029. Two City Scheduling

python solution

https://leetcode.com/problems/two-city-scheduling/

704. Binary Search

python solution

https://leetcode.com/problems/binary-search/

1337. The K Weakest Rows in a Matrix

python solution

https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/

81. Search in Rotated Sorted Array II

python solution

https://leetcode.com/problems/search-in-rotated-sorted-array-ii/

680. Valid Palindrome II

python solution

go solution

https://leetcode.com/problems/valid-palindrome-ii/

1721. Swapping Nodes in a Linked List

python solution

https://leetcode.com/problems/swapping-nodes-in-a-linked-list/

1046. Last Stone Weight

python solution

https://leetcode.com/problems/last-stone-weight/

703. Kth Largest Element in a Stream

python solution

https://leetcode.com/problems/kth-largest-element-in-a-stream/

347. Top K Frequent Elements

python solution

https://leetcode.com/problems/top-k-frequent-elements/

682. Baseball Game

python solution

https://leetcode.com/problems/baseball-game/

289. Game of Life

python solution

https://leetcode.com/problems/game-of-life/

700. Search in a Binary Search Tree

python solution

https://leetcode.com/problems/search-in-a-binary-search-tree/

669. Trim a Binary Search Tree

python solution

https://leetcode.com/problems/trim-a-binary-search-tree/

230. Kth Smallest Element in a BST

python solution

https://leetcode.com/problems/kth-smallest-element-in-a-bst/

173. Binary Search Tree Iterator

python solution

https://leetcode.com/problems/binary-search-tree-iterator/

705. Design HashSet

python solution

https://leetcode.com/problems/design-hashset/

1396. Design Underground System

python solution

https://leetcode.com/problems/design-underground-system/

509. Fibonacci Number

python solution

js solution

ts solution

https://leetcode.com/problems/fibonacci-number/

97. Interleaving String

python solution

https://leetcode.com/problems/interleaving-string/

746. Min Cost Climbing Stairs

python solution

https://leetcode.com/problems/min-cost-climbing-stairs/

108. Convert Sorted Array to Binary Search Tree

python solution

js solution

https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/

804. Unique Morse Code Words

python solution

https://leetcode.com/problems/unique-morse-code-words/

1338. Reduce Array Size to The Half

python solution

https://leetcode.com/problems/reduce-array-size-to-the-half/

387. First Unique Character in a String

python solution

https://leetcode.com/problems/first-unique-character-in-a-string/

About

License:MIT License


Languages

Language:Python 50.8%Language:JavaScript 27.9%Language:Go 20.8%Language:TypeScript 0.5%