https://github.com/gmershad/thedebugger
LeetCode Solution in python.
https://github.com/gmershad/thedebugger
algorithms datastructure datastructures datastructures-algorithms leetcode leetcode-solutions python
Last synced: about 2 months ago
JSON representation
LeetCode Solution in python.
- Host: GitHub
- URL: https://github.com/gmershad/thedebugger
- Owner: gmershad
- Created: 2021-12-26T07:17:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-27T11:40:51.000Z (almost 4 years ago)
- Last Synced: 2025-03-11T10:28:12.441Z (8 months ago)
- Topics: algorithms, datastructure, datastructures, datastructures-algorithms, leetcode, leetcode-solutions, python
- Language: Python
- Homepage:
- Size: 337 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The Debugger - LeetCode
Solution of LeetCode Problems
## Description
This repository has solution of LeetCode problems.
### Linked List
| Title |
| :-------------------------------------------------------------------------------------------------------------------------------- |
| [2. Add Two Numbers](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/addTwoNumbers.py) |
| [19. Remove Nth Node From End of List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/removeNthNodefromend.py) |
| [21. Merge Two Sorted Lists](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/merteTwoSortedList.py) |
| [24. Swap Nodes in Pairs](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/swapNodesInPairs.py) |
| [61. Rotate List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/rotateList.py) |
| [82. Remove Duplicates from Sorted List II](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/deleteDuplicates.py) |
| [83. Remove Duplicates from Sorted List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/deleteDuplicatess.py) |
| [86. Partition List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/partitionList.py) |
| [92. Reverse Linked List II](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/reverseBetween.py) |
| [109. Convert Sorted List to Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/sortedListToBST.py) |
| [114. Flatten Binary Tree to Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/flatten.py) |
| [138. Copy List with Random Pointer](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/copyRandomList.py) |
| [141. Linked List Cycle](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/hasCycle.py) |
| [142. Linked List Cycle II](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/detectCycle.py) |
| [143. Reorder List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/reorderList.py) |
| [147. Insertion Sort List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/insertionSortList.py) |
| [148. Sort List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/sortList.py) |
| [160. Intersection of Two Linked Lists](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/getIntersectionNode.py) |
| [203. Remove Linked List Elements](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/removeElements.py) |
| [206. Reverse Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/reverseList.py) |
| [234. Palindrome Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/isPalindrome.py) |
| [237. Delete Node in a Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/deleteNode.py) |
| [328. Odd Even Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/oddEvenList.py) |
| [355. Design Twitter](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/twitter.py) |
| [382. Linked List Random Node](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/getRandom.py) |
| [430. Flatten a Multilevel Doubly Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/flatten430.py) |
| [445. Add Two Numbers II](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/addTwoNumbersII.py) |
| [622. Design Circular Queue](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/MyCircularQueue.py) |
| [705. Design HashSet](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/MyHashSet.py) |
| [707. Design Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/myLinkedList.py) |
| [876. Middle of the Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/middleNode.py) |
| [1290. Convert Binary Number in a Linked List to Integer](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/getDecimalValue.py) |
| [1367. Linked List in Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/isSubPath.py) |
| [1472. Design Browser History](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/browserHistory.py) |
| [1669. Merge In Between Linked Lists](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/mergeInBetween.py) |
| [1721. Swapping Nodes in a Linked List](https://github.com/gmershad/thedebugger/blob/main/Linked%20List/swapNodes.py) |### Stack
| Title |
| :-------------------------------------------------------------------------------------------------------------------------------- |
| [20. Valid Parentheses](https://github.com/gmershad/thedebugger/blob/main/Stack/validParentheses.py) |
| [32. Longest Valid Parentheses](https://github.com/gmershad/thedebugger/blob/main/Stack/longestValidParentheses.py) |
| [42. Trapping Rain Water](https://github.com/gmershad/thedebugger/blob/main/Stack/trap.py) |
| [94. Binary Tree Inorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Stack/inorderTraversal.py) |
| [114. Flatten Binary Tree to Linked List](https://github.com/gmershad/thedebugger/blob/main/Stack/flatten.py) |
| [143. Reorder List](https://github.com/gmershad/thedebugger/blob/main/Stack/reorderList.py) |
| [144. Binary Tree Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Stack/preorderTraversal.py) |
| [145. Binary Tree Postorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Stack/postorderTraversal.py) |
| [150. Evaluate Reverse Polish Notation](https://github.com/gmershad/thedebugger/blob/main/Stack/evalRPN.py) |
| [155. Min Stack](https://github.com/gmershad/thedebugger/blob/main/Stack/minStack.py) |
| [173. Binary Search Tree Iterator](https://github.com/gmershad/thedebugger/blob/main/Stack/BSTIterator.py) |
| [225. Implement Stack using Queues](https://github.com/gmershad/thedebugger/blob/main/Stack/myStack.py) |
| [232. Implement Queue using Stacks](https://github.com/gmershad/thedebugger/blob/main/Stack/myQueue.py) |
| [234. Palindrome Linked List](https://github.com/gmershad/thedebugger/blob/main/Stack/isPalindrome.py) |
| [316. Remove Duplicate Letters](https://github.com/gmershad/thedebugger/blob/main/Stack/removeDuplicateLetters.py) |
| [402. Remove K Digits](https://github.com/gmershad/thedebugger/blob/main/Stack/removeKdigits.py) |
| [445. Add Two Numbers II](https://github.com/gmershad/thedebugger/blob/main/Stack/addTwoNumbers.py) |
| [456. 132 Pattern](https://github.com/gmershad/thedebugger/blob/main/Stack/find132pattern.py) |
| [589. N-ary Tree Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Stack/preorder.py) |
| [590. N-ary Tree Postorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Stack/postorder.py) |
| [654. Maximum Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Stack/constructMaximumBinaryTree.py) |
| [678. Valid Parenthesis String](https://github.com/gmershad/thedebugger/blob/main/Stack/checkValidString.py) |
| [682. Baseball Game](https://github.com/gmershad/thedebugger/blob/main/Stack/calPoints.py) |
| [735. Asteroid Collision](https://github.com/gmershad/thedebugger/blob/main/Stack/asteroidCollision.py) |
| [739. Daily Temperatures](https://github.com/gmershad/thedebugger/blob/main/Stack/dailyTemperatures.py) |
| [844. Backspace String Compare](https://github.com/gmershad/thedebugger/blob/main/Stack/backspaceCompare.py) |
| [897. Increasing Order Search Tree](https://github.com/gmershad/thedebugger/blob/main/Stack/increasingBST.py) |
| [1008. Construct Binary Search Tree from Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Stack/bstFromPreorder.py) |
| [1021. Remove Outermost Parentheses](https://github.com/gmershad/thedebugger/blob/main/Stack/removeOuterParentheses.py) |
| [1047. Remove All Adjacent Duplicates In String](https://github.com/gmershad/thedebugger/blob/main/Stack/removeDuplicates.py) |
| [1441. Build an Array With Stack Operations](https://github.com/gmershad/thedebugger/blob/main/Stack/buildArray.py) |
| [1472. Design Browser History](https://github.com/gmershad/thedebugger/blob/main/Stack/browserHistory.py) |
| [1598. Crawler Log Folder](https://github.com/gmershad/thedebugger/blob/main/Stack/minOperations.py) |
| [1700. Number of Students Unable to Eat Lunch](https://github.com/gmershad/thedebugger/blob/main/Stack/countStudents.py) |### Queue
| Title |
| :-------------------------------------------------------------------------------------------------------------------------------- |
| [225. Implement Stack using Queues](https://github.com/gmershad/thedebugger/blob/main/Queue/myStack.py) |
| [232. Implement Queue using Stacks](https://github.com/gmershad/thedebugger/blob/main/Queue/myQueue.py) |
| [387. First Unique Character in a String](https://github.com/gmershad/thedebugger/blob/main/Queue/firstUniqChar.py) |
| [622. Design Circular Queue](https://github.com/gmershad/thedebugger/blob/main/Queue/myCircularQueue.py) |
| [1352. Product of the Last K Numbers](https://github.com/gmershad/thedebugger/blob/main/Queue/productOfNumbers.py) |
| [1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://github.com/gmershad/thedebugger/blob/main/Queue/longestSubarray.py)|
| [1700. Number of Students Unable to Eat Lunch](https://github.com/gmershad/thedebugger/blob/main/Queue/countStudents.py) |### Tree/Binary Tree
| Title |
| :-------------------------------------------------------------------------------------------------------------------------------- |
| [94. Binary Tree Inorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/inorderTraversal.py) |
| [96. Unique Binary Search Trees](https://github.com/gmershad/thedebugger/blob/main/Tree/numTrees.py) |
| [98. Validate Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isValidBST.py) |
| [99. Recover Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/recoverTree.py) |
| [100. Same Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isSameTree.py) |
| [101. Symmetric Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isSymmetric.py) |
| [102. Binary Tree Level Order Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/levelOrder.py) |
| [104. Maximum Depth of Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/maxDepth.py) |
| [105. Construct Binary Tree from Preorder and Inorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/buildTree.py) |
| [106. Construct Binary Tree from Inorder and Postorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/buildTree1.py) |
| [108. Convert Sorted Array to Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/sortedArrayToBST.py) |
| [109. Convert Sorted List to Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/sortedArrayToBST.py) |
| [110. Balanced Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isBalanced.py) |
| [111. Minimum Depth of Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/minDepth.py) |
| [112. Path Sum](https://github.com/gmershad/thedebugger/blob/main/Tree/hasPathSum.py) |
| [113. Path Sum II](https://github.com/gmershad/thedebugger/blob/main/Tree/pathSum.py) |
| [114. Flatten Binary Tree to Linked List](https://github.com/gmershad/thedebugger/blob/main/Tree/flatten.py) |
| [116. Populating Next Right Pointers in Each Node](https://github.com/gmershad/thedebugger/blob/main/Tree/connect.py) |
| [117. Populating Next Right Pointers in Each Node II](https://github.com/gmershad/thedebugger/blob/main/Tree/connect1.py) |
| [129. Sum Root to Leaf Numbers](https://github.com/gmershad/thedebugger/blob/main/Tree/sumNumbers.py) |
| [144. Binary Tree Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/preorderTraversal.py) |
| [145. Binary Tree Postorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/postorderTraversal.py) |
| [173. Binary Search Tree Iterator](https://github.com/gmershad/thedebugger/blob/main/Tree/BSTIterator.py) |
| [199. Binary Tree Right Side View](https://github.com/gmershad/thedebugger/blob/main/Tree/rightSideView.py) |
| [222. Count Complete Tree Nodes](https://github.com/gmershad/thedebugger/blob/main/Tree/countNodes.py) |
| [226. Invert Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/invertTree.py) |
| [230. Kth Smallest Element in a BST](https://github.com/gmershad/thedebugger/blob/main/Tree/kthSmallest.py) |
| [235. Lowest Common Ancestor of a Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/lowestCommonAncestor.py) |
| [257. Binary Tree Paths](https://github.com/gmershad/thedebugger/blob/main/Tree/binaryTreePaths.py) |
| [337. House Robber III](https://github.com/gmershad/thedebugger/blob/main/Tree/rob.py) |
| [404. Sum of Left Leaves](https://github.com/gmershad/thedebugger/blob/main/Tree/sumOfLeftLeaves.py) |
| [437. Path Sum III](https://github.com/gmershad/thedebugger/blob/main/Tree/pathSumIII.py) |
| [450. Delete Node in a BST](https://github.com/gmershad/thedebugger/blob/main/Tree/deleteNode.py) |
| [508. Most Frequent Subtree Sum](https://github.com/gmershad/thedebugger/blob/main/Tree/findFrequentTreeSum.py) |
| [513. Find Bottom Left Tree Value](https://github.com/gmershad/thedebugger/blob/main/Tree/findBottomLeftValue.py) |
| [515. Find Largest Value in Each Tree Row](https://github.com/gmershad/thedebugger/blob/main/Tree/largestValues.py) |
| [530. Minimum Absolute Difference in BST](https://github.com/gmershad/thedebugger/blob/main/Tree/getMinimumDifference.py) |
| [543. Diameter of Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/diameterOfBinaryTree.py) |
| [559. Maximum Depth of N-ary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/maxDepth1.py) |
| [563. Binary Tree Tilt](https://github.com/gmershad/thedebugger/blob/main/Tree/findTilt.py) |
| [572. Subtree of Another Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isSubtree.py) |
| [589. N-ary Tree Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/preorder.py) |
| [590. N-ary Tree Postorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/postorder.py) |
| [606. Construct String from Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/tree2str.py) |
| [617. Merge Two Binary Trees](https://github.com/gmershad/thedebugger/blob/main/Tree/mergeTrees.py) |
| [623. Add One Row to Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/addOneRow.py) |
| [637. Average of Levels in Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/averageOfLevels.py) |
| [653. Two Sum IV - Input is a BST](https://github.com/gmershad/thedebugger/blob/main/Tree/findTarget.py) |
| [654. Maximum Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/constructMaximumBinaryTree.py) |
| [669. Trim a Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/trimBST.py) |
| [671. Second Minimum Node In a Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/findSecondMinimumValue.py) |
| [687. Longest Univalue Path](https://github.com/gmershad/thedebugger/blob/main/Tree/longestUnivaluePath.py) |
| [700. Search in a Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/searchBST.py) |
| [703. Kth Largest Element in a Stream](https://github.com/gmershad/thedebugger/blob/main/Tree/KthLargest.py) |
| [783. Minimum Distance Between BST Nodes](https://github.com/gmershad/thedebugger/blob/main/Tree/minDiffInBST.py) |
| [814. Binary Tree Pruning](https://github.com/gmershad/thedebugger/blob/main/Tree/pruneTree.py) |
| [865. Smallest Subtree with all the Deepest Nodes](https://github.com/gmershad/thedebugger/blob/main/Tree/subtreeWithAllDeepest.py) |
| [872. Leaf-Similar Trees](https://github.com/gmershad/thedebugger/blob/main/Tree/leafSimilar.py) |
| [889. Construct Binary Tree from Preorder and Postorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/constructFromPrePost.py) |
| [894. All Possible Full Binary Trees](https://github.com/gmershad/thedebugger/blob/main/Tree/allPossibleFBT.py) |
| [897. Increasing Order Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/increasingBST.py) |
| [919. Complete Binary Tree Inserter](https://github.com/gmershad/thedebugger/blob/main/Tree/CBTInserter.py) |
| [938. Range Sum of BST](https://github.com/gmershad/thedebugger/blob/main/Tree/rangeSumBST.py) |
| [951. Flip Equivalent Binary Trees](https://github.com/gmershad/thedebugger/blob/main/Tree/flipEquiv.py) |
| [958. Check Completeness of a Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isCompleteTree.py) |
| [965. Univalued Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isUnivalTree.py) |
| [971. Flip Binary Tree To Match Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/flipMatchVoyage.py) |
| [979. Distribute Coins in Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/distributeCoins.py) |
| [988. Smallest String Starting From Leaf](https://github.com/gmershad/thedebugger/blob/main/Tree/smallestFromLeaf.py) |
| [1008. Construct Binary Search Tree from Preorder Traversal](https://github.com/gmershad/thedebugger/blob/main/Tree/bstFromPreorder.py) |
| [1022. Sum of Root To Leaf Binary Numbers](https://github.com/gmershad/thedebugger/blob/main/Tree/sumRootToLeaf.py) |
| [1026. Maximum Difference Between Node and Ancestor](https://github.com/gmershad/thedebugger/blob/main/Tree/maxAncestorDiff.py) |
| [1038. Binary Search Tree to Greater Sum Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/bstToGst.py) |
| [1080. Insufficient Nodes in Root to Leaf Paths](https://github.com/gmershad/thedebugger/blob/main/Tree/sufficientSubset.py) |
| [1110. Delete Nodes And Return Forest](https://github.com/gmershad/thedebugger/blob/main/Tree/delNodes.py) |
| [1123. Lowest Common Ancestor of Deepest Leaves](https://github.com/gmershad/thedebugger/blob/main/Tree/lcaDeepestLeaves.py) |
| [1161. Maximum Level Sum of a Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/maxLevelSum.py) |
| [1261. Find Elements in a Contaminated Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/findElements.py) |
| [1302. Deepest Leaves Sum](https://github.com/gmershad/thedebugger/blob/main/Tree/deepestLeavesSum.py) |
| [1305. All Elements in Two Binary Search Trees](https://github.com/gmershad/thedebugger/blob/main/Tree/getAllElements.py) |
| [1315. Sum of Nodes with Even-Valued Grandparent](https://github.com/gmershad/thedebugger/blob/main/Tree/sumEvenGrandparent.py) |
| [1325. Delete Leaves With a Given Value](https://github.com/gmershad/thedebugger/blob/main/Tree/removeLeafNodes.py) |
| [1339. Maximum Product of Splitted Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/maxProduct.py) |
| [1367. Linked List in Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/isSubPath.py) |
| [1372. Longest ZigZag Path in a Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/longestZigZag.py) |
| [1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/getTargetCopy.py) |
| [1382. Balance a Binary Search Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/balanceBST.py) |
| [1448. Count Good Nodes in Binary Tree](https://github.com/gmershad/thedebugger/blob/main/Tree/goodNodes.py) |
## Authors
[@Gul Ershad](https://mailtogulershad.medium.com/)
## Acknowledgments
* [LeetCode](https://leetcode.com/)