Skip to content

Python Solutions of LeetCode Problems. Daily Update. If you like this, please leave me a star. ★ :octocat:

License

Notifications You must be signed in to change notification settings

YuriSpiridonov/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python solutions of LeetCode problems.

Language  Problems Solved  License  Update 

Project on summer pause :)

Introduction

In this repository provided my Python solutions of LeetCode problems.

  • I highly recommend you to try and solve problems yourself before look at the solutions here.
  • Solutions and approaches may be not optimal (I'm learning and practicing DSA & committing my solutions).
  • All Solutions here are in Python 3.

LeetCoding Challenges

2020:

2021:



Solutions

P.S. If you like this, please leave me a star.

Title Solution Difficulty Note
1. Two Sum Python Easy
1. Two Sum Python Easy optimized soln
2. Add Two Numbers Python Medium Linked List + brute force
3. Longest Substring Without Repeating Characters Python Medium Kinda brute force
4. Median of Two Sorted Arrays Python Hard
5. Longest Palindromic Substring Python Medium Brute Force
7. Reverse Integer Python Easy
9. Palindrome Number Python Easy Without converting integer into string
11. Container With Most Water Python Medium Two Pointers
12. Integer to Roman Python Medium
13. Roman to Integer Python Easy
14. Longest Common Prefix Python Easy
15. 3Sum Python Medium Brute Force
16. 3Sum Closest Python Medium Brute Force
17. Letter Combinations of a Phone Number Python Medium DFS, Recursion
19. Remove Nth Node From End of List Python Medium Stack
20. Valid Parentheses Python Easy Brute Force
20. Valid Parentheses Python Easy Stack
21. Merge Two Sorted Lists Python Easy Linked List
23. Merge k Sorted Lists Python Hard Linked List, not exactly what was aked
24. Swap Nodes in Pairs Python Medium Linked List
25. Reverse Nodes in k-Group Python Hard Linked List, Stack
26. Remove Duplicates from Sorted Array Python Easy Several solutions in one file
27. Remove Element Python Easy
29. Divide Two Integers Python Medium
33. Search in Rotated Sorted Array Python Medium
34. Find First and Last Position of Element in Sorted Array Python Medium Binary Search
34. Find First and Last Position of Element in Sorted Array Python Medium
35. Search Insert Position Python Easy Binary Search
36. Valid Sudoku Python Medium Brute Force, set, list
41. First Missing Positive Python Hard
46. Permutations Python Medium Itertools
47. Permutations II Python Medium Itertools
48. Rotate Image Python Medium
49. Group Anagrams Python Medium
50. Pow(x, n) Python Medium Recursion
53. Maximum Subarray Python Easy
54. Spiral Matrix Python Medium
55. Jump Game Python Medium
56. Merge Intervals Python Medium
57. Insert Interval Python Hard
58. Length of Last Word Python Easy List
58. Length of Last Word Python Easy String
59. Spiral Matrix II Python Medium spaghetti
61. Rotate List Python Medium Linked List
63. Unique Paths II Python Medium DP
64. Minimum Path Sum Python Medium
66. Plus One Python Easy
67. Add Binary Python Easy
71. Simplify Path Python Medium Stack
73. Set Matrix Zeroes Python Medium set()
74. Search a 2D Matrix Python Medium Binary Search
75. Sort Colors Python Medium Bubble Sort
75. Sort Colors Python Medium Selection Sort
75. Sort Colors Python Medium Insertion Sort
75. Sort Colors Python Medium Quick Sort
75. Sort Colors Python Medium Merge Sort
78. Subsets Python Medium itertools.combinations()
80. Remove Duplicates from Sorted Array II Python Medium
81. Search in Rotated Sorted Array II Python Medium
82. Remove Duplicates from Sorted List II Python Medium Linked List
83. Remove Duplicates from Sorted List Python Easy Linked List
86. Partition List Python Medium Linked List
88. Merge Sorted Array Python Easy Two solutions
92. Reverse Linked List II Python Medium Stack, Linked List
94. Binary Tree Inorder Traversal Python Medium Binary Tree, Recursion
98. Validate Binary Search Tree Python Medium Binary Tree, Recursion
98. Validate Binary Search Tree Python Medium Binary Tree, Recursion, another valid. approach
100. Same Tree Python Easy Binary Tree (preorder), Recursion
101. Symmetric Tree Python Easy BFS, iteratively
102. Binary Tree Level Order Traversal Python Medium BFS, Overcode
103. Binary Tree Zigzag Level Order Traversal Python Medium BFS
104. Maximum Depth of Binary Tree Python Easy Binary Tree, Recursion
107. Binary Tree Level Order Traversal II Python Easy BFS
110. Balanced Binary Tree Python Easy DFS, Recursion
111. Minimum Depth of Binary Tree Python Easy Binary Tree, Recursion
112. Path Sum Python Easy Binary Tree, Recursion
114. Flatten Binary Tree to Linked List Python Medium DFS, preorder
116. Populating Next Right Pointers in Each Node Python Medium BFS
117. Populating Next Right Pointers in Each Node II Python Medium BFS, same as 116
118. Pascal's Triangle Python Easy
119. Pascal's Triangle II Python Easy
120. Triangle Python Medium
121. Best Time to Buy and Sell Stock Python Easy
122. Best Time to Buy and Sell Stock II Python Easy
123. Best Time to Buy and Sell Stock III Python Hard
124. Binary Tree Maximum Path Sum Python Hard
125. Valid Palindrome Python Easy Two pointers from start & end
125. Valid Palindrome Python Easy Re.findall and left half == rev. right half
125. Valid Palindrome Python Easy Re.sub and s == reversed s
128. Longest Consecutive Sequence Python Medium
129. Sum Root to Leaf Numbers Python Medium DFS
134. Gas Station Python Medium
136. Single Number Python Easy
137. Single Number II Python Medium Brute Force
138. Copy List with Random Pointer Python Medium Linked List
139. Word Break Python Medium Watched how to complete
141. Linked List Cycle Python Easy Linked List, Brute Force
141. Linked List Cycle Python Easy Linked List, set()
142. Linked List Cycle II Python Medium Linked List, set()
143. Reorder List Python Medium Linked List, Stack
144. Binary Tree Preorder Traversal Python Medium Binary Tree, Recursion
145. Binary Tree Postorder Traversal Python Hard Binary Tree, Recursion
146. LRU Cache Python Medium
147. Insertion Sort List Python Medium Not exactly what asked, Linked List, Binary Search
148. Sort List Python Medium Linked List, Brute Force
150. Evaluate Reverse Polish Notation Python Medium Stack
152. Maximum Product Subarray Python Medium DP
153. Find Minimum in Rotated Sorted Array Python Medium For loop
153. Find Minimum in Rotated Sorted Array Python Medium Binary Search
154. Find Minimum in Rotated Sorted Array II Python Hard For loop
155. Min Stack Python Easy
160. Intersection of Two Linked Lists Python Easy Linked List
162. Find Peak Element Python Medium
164. Maximum Gap Python Hard
165. Compare Version Numbers Python Medium
167. Two Sum II - Input array is sorted Python Easy
168. Excel Sheet Column Title Python Easy
171. Excel Sheet Column Number Python Easy
172. Factorial Trailing Zeroes Python Easy Brute Force
173. Binary Search Tree Iterator Python Medium inorder
179. Largest Number Python Medium Bubble sort
191. Number of 1 Bits Python Easy
198. House Robber Python Easy
199. Binary Tree Right Side View Python Medium BFS
200. Number of Islands Python Medium
201. Bitwise AND of Numbers Range Python Medium
202. Happy Number Python Easy
203. Remove Linked List Elements Python Easy Linked List
204. Count Primes Python Easy
205. Isomorphic Strings Python Easy Dictionary
206. Reverse Linked List Python Easy Linked List, brute force
206. Reverse Linked List Python Easy Linked List
208. Implement Trie (Prefix Tree) Python Medium Trie, 1st time all by myself
209. Minimum Size Subarray Sum Python Medium
211. Add and Search Word - Data structure design Python Medium Need to resolve
215. Kth Largest Element in an Array Python Medium sorted()
216. Combination Sum III Python Medium Backtracking
217. Contains Duplicate Python Easy Dictionary
219. Contains Duplicate II Python Easy Dictionary, enumerate
220. Contains Duplicate III Python Medium Two pointers?
221. Maximal Square Python Medium
222. Count Complete Tree Nodes Python Medium Recursion
225. Implement Stack using Queues Python Easy List
226. Invert Binary Tree Python Easy Recursion
227. Basic Calculator II Python Medium Queue, Brute Force
228. Summary Ranges Python Medium Two Pointers
229. Majority Element II Python Medium Brute Force
229. Majority Element II Python Medium a bit optimized
230. Kth Smallest Element in a BST Python Medium Recursion, inorder, brute force
232. Implement Queue using Stacks Python Easy List
234. Palindrome Linked List Python Easy Linked List
237. Delete Node in a Linked List Python Easy Linked List
238. Product of Array Except Self Python Medium
240. Search a 2D Matrix II Python Medium Binary Search
242. Valid Anagram Python Easy
257. Binary Tree Paths Python Easy Binary Tree (preorder), Recursion
258. Add Digits Python Easy
260. Single Number III Python Medium Set
268. Missing Number Python Easy
274. H-Index Python Medium
275. H-Index II Python Medium Solution for problem #274 worked fine
283. Move Zeroes Python Easy
284. Peeking Iterator Python Medium
289. Game of Life Python Medium
290. Word Pattern Python Easy Dictionary, enumerate
295. Find Median from Data Stream Python Hard Brute Force
295. Find Median from Data Stream Python Hard Binary Search
297. Serialize and Deserialize Binary Tree Python Hard BFS
299. Bulls and Cows Python Easy
304. Range Sum Query 2D - Immutable Python Medium Brute force
304. Range Sum Query 2D - Immutable Python Medium A bit optimized but still brute force
307. Range Sum Query - Mutable [Python](/Medium/307.RangeSumQuery - Mutable.py) Medium
318. Maximum Product of Word Lengths Python Medium Brute Force
326. Power of Three Python Easy while
328. Odd Even Linked List Python Medium Linked List
329. Longest Increasing Path in a Matrix Python Hard DFS, LRU_cache, Brute Force
334. Increasing Triplet Subsequence Python Medium Brute Force
341. Flatten Nested List Iterator Python Medium
342. Power of Four Python Easy Brute Force
342. Power of Four Python Easy Bitwise
344. Reverse String Python Easy
345. Reverse Vowels of a String Python Easy String, in-place, slow
345. Reverse Vowels of a String Python Easy List, fast, ~x4
347. Top K Frequent Elements Python Medium Hash Table
355. Design Twitter Python Medium May be improved with collections
376. Wiggle Subsequence Python Medium
378. Kth Smallest Element in a Sorted Matrix Python Medium Converted matrix into list
380. Insert Delete GetRandom O(1) Python Medium not O(1), Brute force
381. Insert Delete GetRandom O(1) - Duplicates allowed Python Hard not O(1), Brute force
382. Linked List Random Node Python Medium random.choice()
384. Shuffle an Array Python Medium random.sample()
387. First Unique Character in a String Python Easy Brute Force
387. First Unique Character in a String Python Easy Dictionary, enumerate
389. Find the Difference Python Easy set, .count()
389. Find the Difference Python Easy .replace()
392. Is Subsequence Python Easy
394. Decode String Python Medium Stack
395. Longest Substring with At Least K Repeating Characters Python Medium collections, Recursion
398. Random Pick Index Python Medium random.choice()
399. Evaluate Division Python Medium God bless youtube
402. Remove K Digits Python Medium Stack
404. Sum of Left Leaves Python Easy Recursion, preorder
409. Longest Palindrome Python Easy
412. Fizz Buzz Python Easy
421. Maximum XOR of Two Numbers in an Array Python Medium googled soln
423. Reconstruct Original Digits from English Python Medium
429. N-ary Tree Level Order Traversal Python Medium BFS
432. All O`one Data Structure Python Hard Dictionary as Data Structure
435. Non-overlapping Intervals Python Medium lambda
436. Find Right Interval Python Medium Brute Force
437. Path Sum III Python Medium DFS
441. Arranging Coins Python Easy Iteratively
442. Find All Duplicates in an Array Python Medium set()
445. Add Two Numbers II Python Medium converted to int and back to Linked List
449. Serialize and Deserialize BST Python Medium Complicated solution - resolve
450. Delete Node in a BST Python Medium Binary Search Tree, Recursion
451. Sort Characters By Frequency Python Medium Surprisingly fast solution
452. Minimum Number of Arrows to Burst Balloons Python Medium
454. 4Sum II Python Medium Dictionary
456. 132 Pattern Python Medium Brute Force
458. Poor Pigs Python Hard math
459. Repeated Substring Pattern Python Easy
462. Minimum Moves to Equal Array Elements II Python Medium median
468. Validate IP Address Python Medium
470. Implement Rand10() Using Rand7() Python Medium 'Invented the wheel'
476. Number Complement Python Easy
478. Generate Random Point in a Circle Python Medium
495. Teemo Attacking Python Medium
496. Next Greater Element I Python Easy Brute force - resolve
497. Random Point in Non-overlapping Rectangles Python Medium Random, Bisect
498. Diagonal Traverse Python Medium Used theory from GfG.com
500. Keyboard Row Python Easy Dictionary
501. Find Mode in Binary Search Tree Python Easy Recursion
503. Next Greater Element II Python Medium Brute Force
509. Fibonacci Number Python Easy List
509. Fibonacci Number Python Easy Dictionary
509. Fibonacci Number Python Easy Used two variables n1 & n2
513. Find Bottom Left Tree Value Python Medium BFS
515. Find Largest Value in Each Tree Row Python Medium BFS
520. Detect Capital Python Easy Built-in functions
524. Longest Word in Dictionary through Deleting Python Medium
525. Contiguous Array Python Medium
526. Beautiful Arrangement Python Medium DFS, brute force
530. Minimum Absolute Difference in BST Python Easy Bad solution - resolve
532. K-diff Pairs in an Array Python Medium Brute force
535. Encode and Decode TinyURL Python Medium Dictionary as db, random generated url
538. Convert BST to Greater Tree Python Easy DFS, recursion
540. Single Element in a Sorted Array Python Medium Binary Search
543. Diameter of Binary Tree Python Easy
554. Brick Wall Python Medium Hash Table
556. Next Greater Element III Python Medium
559. Maximum Depth of N-ary Tree Python Easy BFS
560. Subarray Sum Equals K Python Medium
563. Binary Tree Tilt Python Easy Binary Tree, postorder, overcode
566. Reshape the Matrix Python Easy Brute Force
575. Distribute Candies Python Easy
581. Shortest Unsorted Continuous Subarray Python Medium
589. N-ary Tree Preorder Traversal Python Easy Recursion
590. N-ary Tree Postorder Traversal Python Easy Recursion
593. Valid Square Python Medium
594. Longest Harmonious Subsequence Python Easy defaultdict
594. Longest Harmonious Subsequence Python Easy Counter
599. Minimum Index Sum of Two Lists Python Easy Dictionary, enumerate
605. Can Place Flowers Python Easy simple counter
609. Find Duplicate File in System Python Medium Dictionary, nested for loop, list comprehension
622. Design Circular Queue Python Medium Implement through list (first time)
623. Add One Row to Tree Python Medium BFS
637. Average of Levels in Binary Tree Python Easy Binary Tree, Recursion
641. Design Circular Deque Python Medium Need to resolve without use of builtin functions (first time)
645. Set Mismatch Python Easy collections.Counter
647. Palindromic Substrings Python Medium
653. Two Sum IV - Input is a BST Python Easy Brute Force - resolve
654. Maximum Binary Tree Python Medium DFS, Recursion
657. Robot Return to Origin Python Easy Dictionary
658. Find K Closest Elements Python Medium Binary Search
665. Non-decreasing Array Python Easy Brute Force
667. Beautiful Arrangement II Python Medium
671. Second Minimum Node In a Binary Tree Python Easy DFS, Recursion
674. Longest Continuous Increasing Subsequence Python Easy simple counter
677. Map Sum Pairs Python Medium Trie
678. Valid Parenthesis String Python Medium
682. Baseball Game Python Easy
690. Employee Importance Python Easy BFS
695. Max Area of Island Python Medium DFS
696. Count Binary Substrings Python Easy
700. Search in a Binary Search Tree Python Easy Binary Search Tree, Recursion
701. Insert into a Binary Search Tree Python Medium Binary Search Tree, Recursion
703. Kth Largest Element in a Stream Python Easy brute force
705. Design HashSet Python Easy list as a set
706. Design HashMap Python Easy list
707. Design Linked List Python Medium Linked List, first time
709. To Lower Case Python Easy Two solutions. 1st w. in place changes, 2nd saves in var
713. Subarray Product Less Than K Python Medium Two pointers
720. Longest Word in Dictionary Python Easy Trie
722. Remove Comments Python Medium String
728. Self Dividing Numbers Python Easy Math
729. My Calendar I Python Medium Limked List, Dictionary
735. Asteroid Collision Python Medium Stack
744. Find Smallest Letter Greater Than Target Python Easy Binary Search
746. Min Cost Climbing Stairs Python Easy DP
754. Reach a Number Python Medium Math
763. Partition Labels Python Medium Brute Force - resolve
771. Jewels and Stones Python Easy while loop, for loop and list comprehension
775. Global and Local Inversions Python Medium
785. Is Graph Bipartite? Python Medium Iteratively BFS, stack, XOR
791. Custom Sort String Python Medium
804. Unique Morse Code Words Python Easy Dictionary
807. Max Increase to Keep City Skyline Python Medium
811. Subdomain Visit Count Python Easy Dictionary
817. Linked List Components Python Medium Set
817. Linked List Components Python Medium List, 35 times slower
820. Short Encoding of Words Python Medium Brute Force
821. Shortest Distance to a Character Python Easy overcode
824. Goat Latin Python Easy
832. Flipping an Image Python Easy
832. Flipping an Image Python Easy .reverse()
835. Image Overlap Python Medium Brute Force
841. Keys and Rooms Python Medium BFS
844. Backspace String Compare Python Easy
845. Longest Mountain in Array Python Medium one pass
849. Maximize Distance to Closest Person Python Medium
852. Peak Index in a Mountain Array Python Easy List comprehension
852. Peak Index in a Mountain Array Python Easy Set
858. Mirror Reflection Python Medium
859. Buddy Strings Python Easy Brute Force
865. Smallest Subtree with all the Deepest Nodes Python Medium DFS, Recursion
869. Reordered Power of 2 Python Medium int to string
872. Leaf-Similar Trees Python Easy Recursion
876. Middle of the Linked List Python Easy
880. Decoded String at Index Python Medium
881. Boats to Save People Python Medium Two Pointers
884. Uncommon Words from Two Sentences Python Easy simple counter
890. Find and Replace Pattern Python Medium Dictionary
895. Maximum Frequency Stack Python Hard
896. Monotonic Array Python Easy
897. Increasing Order Search Tree Python Easy DFS, iteratively
900. RLE Iterator Python Medium
905. Sort Array By Parity Python Easy List
908. Smallest Range I Python Easy
910. Smallest Range II Python Medium
911. Online Election Python Medium Binary Search
912. Sort an Array Python Medium sorted()
916. Word Subsets Python Medium collections.Counter, Dictionary
922. Sort Array By Parity II Python Easy Dictionary
922. Sort Array By Parity II Python Easy List
922. Sort Array By Parity II Python Easy Two Pointers
923. 3Sum With Multiplicity Python Medium collections.Counter
929. Unique Email Addresses Python Easy
933. Number of Recent Calls Python Easy Binary Search and rewrite list
933. Number of Recent Calls Python Easy while and rewrite list
933. Number of Recent Calls Python Easy while and .pop()
938. Range Sum of BST Python Easy Binary Search Tree
938. Range Sum of BST Python Easy Binary Search Tree, Optimized solution
941. Valid Mountain Array Python Easy
946. Validate Stack Sequences Python Medium Stack
949. Largest Time for Given Digits Python Easy Itertools
952. Largest Component Size by Common Factor Python Hard Googled soln
953. Verifying an Alien Dictionary Python Easy
961. N-Repeated Element in Size 2N Array Python Easy Brute Force
961. N-Repeated Element in Size 2N Array Python Easy Dictionary, a bit optimized
965. Univalued Binary Tree Python Easy Binary Tree, Recursion
966. Vowel Spellchecker Python Medium Dictionary
967. Numbers With Same Consecutive Differences Python Medium DFS
969. Pancake Sorting Python Medium sort
970. Powerful Integers Python Medium nested for loops
977. Squares of a Sorted Array Python Easy
980. Unique Paths III Python Hard "googled soln", optimised
981. Time Based Key-Value Store Python Medium Binary Search
983. Minimum Cost For Tickets Python Medium Googled soln
987. Vertical Order Traversal of a Binary Tree Python Medium DFS
989. Add to Array-Form of Integer Python Easy list->int->list
991. Broken Calculator Python Medium BFS
993. Cousins in Binary Tree Python Easy BFS, iteratively
994. Rotting Oranges Python Medium DFS
999. Available Captures for Rook Python Easy
1002. Find Common Characters Python Easy Dictionary
1009. Complement of Base 10 Integer Python Easy
1010. Pairs of Songs With Total Durations Divisible by 60 Python Medium
1015. Smallest Integer Divisible by K Python Medium counting lenght, Brute Force
1019. Next Greater Node In Linked List Python Medium
1021. Remove Outermost Parentheses Python Easy Overcode
1022. Sum of Root To Leaf Binary Numbers Python Easy DFS, Recursion
1025. Divisor Game Python Easy
1026. Maximum Difference Between Node and Ancestor Python Medium BFS, iteratively
1032. Stream of Characters Python Hard Trie
1038. Binary Search Tree to Greater Sum Tree Python Medium DFS, recursion
1041. Robot Bounded In Circle Python Medium Dictionary
1046. Last Stone Weight Python Easy
1047. Remove All Adjacent Duplicates In String Python Easy Brute force - resolve
1079. Letter Tile Possibilities Python Medium itertools, permutations
1091. Shortest Path in Binary Matrix Python Medium BFS, grid/matrix
1094. Car Pooling Python Medium
1095. Find in Mountain Array Python Hard Binary Search
1103. Distribute Candies to People Python Easy
1108. Defanging an IP Address Python Easy .replace()
1108. Defanging an IP Address Python Easy re.sub
1108. Defanging an IP Address Python Easy .join()
1122. Relative Sort Array Python Easy
1123. Lowest Common Ancestor of Deepest Leaves Python Medium DFS, recursion
1143. Longest Common Subsequence Python Medium 2D Array
1143. Longest Common Subsequence Python Medium Recursion, Time Limit Exceeded
1160. Find Words That Can Be Formed by Characters Python Easy Dictionary
1161. Maximum Level Sum of a Binary Tree Python Medium BFS
1169. Invalid Transactions Python Medium Ugly brute force
1171. Remove Zero Sum Consecutive Nodes from Linked List Python Medium Brute Force - resolve
1189. Maximum Number of Balloons Python Easy simple counter
1200. Minimum Absolute Difference Python Easy Dictionary
1207. Unique Number of Occurrences Python Easy Dictionary
1217. Minimum Cost to Move Chips to The Same Position Python Easy simple counter
1221. Split a String in Balanced Strings Python Easy Stack
1227. Airplane Seat Assignment Probability Python Medium
1237. Find Positive Integer Solution for a Given Equation Python Easy Binary Search
1252. Cells with Odd Values in a Matrix Python Easy
1260. Shift 2D Grid Python Easy array
1261. Find Elements in a Contaminated Binary Tree Python Medium DFS, iteratively
1266. Minimum Time Visiting All Points Python Easy simple counter
1268. Search Suggestions System Python Medium Brute Force
1282. Group the People Given the Group Size They Belong To Python Medium
1283. Find the Smallest Divisor Given a Threshold Python Medium Binary Search
1286. Iterator for Combination Python Medium Itertools
1287. Element Appearing More Than 25% In Sorted Array Python Easy for loop
1287. Element Appearing More Than 25% In Sorted Array Python Easy Binary Search
1288. Remove Covered Intervals Python Medium Brute force
1290. Convert Binary Number in a Linked List to Integer Python Easy
1291. Sequential Digits Python Medium String, can be solved with int
1299. Replace Elements with Greatest Element on Right Side Python Easy
1302. Deepest Leaves Sum Python Medium DFS
1304. Find N Unique Integers Sum up to Zero Python Easy
1305. All Elements in Two Binary Search Trees Python Medium BFS, iteratively
1306. Jump Game III Python Medium BFS, iteratively
1309. Decrypt String from Alphabet to Integer Mapping Python Easy
1311. Get Watched Videos by Your Friends Python Medium BFS, iteratively
1313. Decompress Run-Length Encoded List Python Easy
1315. Sum of Nodes with Even-Valued Grandparent Python Medium DFS, recursion
1323. Maximum 69 Number Python Easy
1325. Delete Leaves With a Given Value Python Medium DFS, recursion
1329. Sort the Matrix Diagonally Python Medium List
1331. Rank Transform of an Array Python Easy Enumerate
1332. Remove Palindromic Subsequences Python Easy Bad problem question
1337. The K Weakest Rows in a Matrix Python Easy
1338. Reduce Array Size to The Half Python Medium Dictionary, Enumerate
1342. Number of Steps to Reduce a Number to Zero Python Easy while loop
1345. Jump Game IV Python Hard BFS, iteratively
1347. Minimum Number of Steps to Make Two Strings Anagram Python Medium
1348. Tweet Counts Per Frequency Python Medium Too slow, need to resolve it
1351. Count Negative Numbers in a Sorted Matrix Python Easy Binary Search
1351. Count Negative Numbers in a Sorted Matrix Python Easy nested for loop
1351. Count Negative Numbers in a Sorted Matrix Python Easy nested for loop with a break
1352. Product of the Last K Numbers Python Medium Brute Force
1352. Product of the Last K Numbers Python Medium Optimized, but overcode
1352. Product of the Last K Numbers Python Medium
1357. Apply Discount Every n Orders Python Medium Brute Force
1357. Apply Discount Every n Orders Python Medium Dictionary
1361. Validate Binary Tree Nodes Python Medium BFS, iteratively
1365. How Many Numbers Are Smaller Than the Current Number Python Easy List comprehension
1367. Linked List in Binary Tree Python Medium DFS, Linked List, Binary Tree
1370. Increasing Decreasing String Python Easy
1374. Generate a String With Characters That Have Odd Counts Python Easy
1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree Python Medium Stack, iteratively
1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree Python Medium DFS, recursion
1380. Lucky Numbers in a Matrix Python Easy Nested for loops
1381. Design a Stack With Increment Operation Python Medium List as Stack
1387. Sort Integers by The Power Value Python Medium
1389. Create Target Array in the Given Order Python Easy enumerate, insert
1395. Count Number of Teams Python Medium Brute Force
1396. Design Underground System Python Medium Dictionary
1403. Minimum Subsequence in Non-Increasing Order Python Easy List
1403. Minimum Subsequence in Non-Increasing Order Python Easy sum (int) comparison
1409. Queries on a Permutation With Key Python Medium
1410. HTML Entity Parser Python Medium Re.sub
1414. Find the Minimum Number of Fibonacci Numbers Whose Sum Is K Python Medium Greedy
1423. Maximum Points You Can Obtain from Cards Python Medium Sliding Window
1426. Counting Elements Python Easy
1427. Perform String Shifts Python Easy
1428. Leftmost Column with at Least a One Python Medium
1429. First Unique Number Python Medium
1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree Python Medium
1431. Kids With the Greatest Number of Candies Python Easy List comprehension
1436. Destination City Python Easy Dictionary
1436. Destination City Python Easy Set
1437. Check If All 1's Are at Least Length K Places Away Python Medium
1441. Build an Array With Stack Operations Python Easy List
1446. Consecutive Characters Python Easy Two pointers
1448. Count Good Nodes in Binary Tree Python Medium DFS, Binary Tree
1448. Count Good Nodes in Binary Tree Python Medium optimized DFS, Binary Tree
1450. Number of Students Doing Homework at a Given Time Python Easy Enumerate
1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence Python Easy Enumerate
1457. Pseudo-Palindromic Paths in a Binary Tree Python Medium DFS, recursion
1460. Make Two Arrays Equal by Reversing Sub-arrays Python Easy
1461. Check If a String Contains All Binary Codes of Size K Python Medium Brute Force
1463. Cherry Pickup II Python Hard DFS, lfu cache
1464. Maximum Product of Two Elements in an Array Python Easy
1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts Python Medium
1470. Shuffle the Array Python Easy Zip
1472. Design Browser History Python Medium Doubly Linked List
1472. Design Browser History Python Medium Dictionary
1475. Final Prices With a Special Discount in a Shop Python Easy kinda Brute force
1476. Subrectangle Queries Python Medium nested for loop
1480. Running Sum of 1d Array Python Easy
1480. Running Sum of 1d Array Python Easy List comprehension
1486. XOR Operation in an Array Python Easy
1487. Making File Names Unique Python Medium
1491. Average Salary Excluding the Minimum and Maximum Salary Python Easy
1492. The kth Factor of n Python Medium
1496. Path Crossing Python Easy
1502. Can Make Arithmetic Progression From Sequence Python Easy
1507. Reformat Date Python Easy List
1507. Reformat Date Python Easy Without conberting String into List
1512. Number of Good Pairs Python Easy Dictionary
1512. Number of Good Pairs Python Easy Nested for loops
1518. Water Bottles Python Easy While loop
1523. Count Odd Numbers in an Interval Range Python Easy
1528. Shuffle String Python Easy List
1528. Shuffle String Python Easy String
1534. Count Good Triplets Python Easy
1539. Kth Missing Positive Number Python Easy List
1544. Make The String Great Python Easy Stack
1544. Make The String Great Python Easy String in-place
1545. Find Kth Bit in Nth Binary String Python Medium Brute Force
1550. Three Consecutive Odds Python Easy simple counter
1551. Minimum Operations to Make Array Equal Python Medium
1556. Thousand Separator Python Easy String, List
1557. Minimum Number of Vertices to Reach All Nodes Python Medium Set, kinda Brute Force
1561. Maximum Number of Coins You Can Get Python Medium
1566. Detect Pattern of Length M Repeated K or More Times Python Easy
1567. Maximum Length of Subarray With Positive Product Python Medium kinda Brute force
1572. Matrix Diagonal Sum Python Easy
1576. Replace All ?'s to Avoid Consecutive Repeating Characters Python Easy Fast but awful soln.
1582. Special Positions in a Binary Matrix Python Easy
1588. Sum of All Odd Length Subarrays Python Easy Two Pointers
1592. Rearrange Spaces Between Words Python Easy
1598. Crawler Log Folder Python Easy
1603. Design Parking System Python Easy Dictionary
1609. Even Odd Tree Python Medium BFS
1614. Maximum Nesting Depth of the Parentheses Python Easy
1619. Mean of Array After Removing Some Elements Python Easy
1624. Largest Substring Between Two Equal Characters Python Easy
1629. Slowest Key Python Easy
1630. Arithmetic Subarrays Python Medium
1631. Path With Minimum Effort Python Medium DFS, Binary Search, Brute force
1636. Sort Array by Increasing Frequency Python Easy complicated counter
1637. Widest Vertical Area Between Two Points Containing No Points Python Medium
1640. Check Array Formation Through Concatenation Python Easy
1641. Count Sorted Vowel Strings Python Medium itertools
1646. Get Maximum in Generated Array Python Easy while
1646. Get Maximum in Generated Array Python Easy for
1652. Defuse the Bomb Python Easy
1656. Design an Ordered Stream Python Easy list
1657. Determine if Two Strings Are Close Python Medium collections.Counter
1658. Minimum Operations to Reduce X to Zero Python Medium
1662. Check If Two String Arrays are Equivalent Python Easy .join()
1663. Smallest String With A Given Numeric Value Python Medium
1668. Maximum Repeating Substring Python Easy
1669. Merge In Between Linked Lists Python Medium Linked List
1670. Design Front Middle Back Queue Python Medium List
1672. Richest Customer Wealth Python Easy
1673. Find the Most Competitive Subsequence Python Medium Stack
1678. Goal Parser Interpretation Python Easy .replace()
1678. Goal Parser Interpretation Python Easy iteratively
1679. Max Number of K-Sum Pairs Python Medium collections, Counter
1680. Concatenation of Consecutive Binary Numbers Python Medium
1684. Count the Number of Consistent Strings Python Easy
1685. Sum of Absolute Differences in a Sorted Array Python Medium
1688. Count of Matches in Tournament Python Easy simple counter
1689. Partitioning Into Minimum Number Of Deci-Binary Numbers Python Medium max()
1694. Reformat Phone Number Python Easy
1695. Maximum Erasure Value Python Medium
1700. Number of Students Unable to Eat Lunch Python Easy simple counter
1704. Determine if String Halves Are Alike Python Easy simple counter
1710. Maximum Units on a Truck Python Easy Dictionary
1716. Calculate Money in Leetcode Bank Python Easy
1720. Decode XORed Array Python Easy
1721. Swapping Nodes in a Linked List Python Medium Linked List, Queue
1725. Number Of Rectangles That Can Form The Largest Square Python Easy collections.defaultdict
1732. Find the Highest Altitude Python Easy
1748. Sum of Unique Elements Python Easy collections.Counter
1752. Check if Array Is Sorted and Rotated Python Easy
1773. Count Items Matching a Rule Python Easy
1790. Check if One String Swap Can Make Strings Equal Python Easy
1791. Find Center of Star Graph Python Medium
1796. Second Largest Digit in a String Python Easy
1800. Maximum Ascending Subarray Sum Python Easy
1805. Number of Different Integers in a String Python Easy
1812. Determine Color of a Chessboard Square Python Easy
1816. Truncate Sentence Python Easy

License

The code is open-source and licensed under the MIT license.

About

Python Solutions of LeetCode Problems. Daily Update. If you like this, please leave me a star. ★ :octocat:

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages