Skip to content

This is leetcode solution in Java with eplaination and generalization.

Notifications You must be signed in to change notification settings

venciallee/leetcode-in-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 

Repository files navigation

leetcode-in-Java

This is leetcode solution in Java with eplaination and generalization.

LinkedList

# Title Solution Difficulty Source Code
2 Add Two Numbers math Medium AddTwoNums.java
19 Remove Nth Node From End of List Medium RemoveNthNode.java
21 Merge Two Sorted Lists loop and sort node easy MergeTwoSortedLists.java
23 Merge k Sorted Lists Divide and Conquer + mergeTwoSortedLists Hard MergekSortedLists.java
24 Swap Nodes in Pairs recursive + swap node Medium SwapNodesInPairs.java
61 Rotate List connect tail and head & cut the right k places node Medium RotateList.java
82 Remove Duplicates from Sorted List II find duplicate node and store duplicate state, update next pointer Medium RemoveDuplicatesFromSortedListII.java
83 Remove Duplicates from Sorted List find duplicate node and update pointer next to next.next Medium RemoveDuplicatesFromSortedList.java
86 Partition List Two Pointer Medium PartitionList.java
92 Reverse Linked List II like Insertion Sort Medium ReverseLinkedListII.java
109 Convert Sorted List to Binary Search Tree pre-order traversal Medium ConvertSortedListtoBST.java
138 Copy List with Random Pointer recursive + hashmap Medium CopyListwithRandomPointer.java
141 Linked List Cycle two pointer Easy LinkedListCycle.java
142 Linked List Cycle II hashset or two pointer Medium LinkedListCycleII.java
143 Reorder List reverse + connect Medium ReorderList.java
147 Insertion Sort List insertion algorithm Medium InsertionSortList.java
148 Sort List two pointer + merge sort algorithm Medium SortList.java
160 Intersection of Two Linked Lists iteration Medium IntersectionofTwoLinkedLists.java
203 Remove Linked List Elements slow pointer + connect Easy RemoveLinkedListElements.java
206 Reverse Linked List Easy ReverseLinkedList.java
234 Palindrome Linked List reverse + equal Easy PalindromeLinkedList.java
328 Odd Even Linked List connect next.next pointer Medium OddEvenLinkedList.java
430 Flatten a Multilevel Doubly Linked List Medium FlattenMultilevelDoublyLinkedList.java
445 Add Two Numbers II reverse Medium AddTwoNumbersII.java
725 Split Linked List in Parts Medium SplitLinkedListinParts.java
817 Linked List Components Medium LinkedListComponents.java
876 Middle of the Linked List two pointer Easy MiddleoftheLinkedList.java
1029 Next Greater Node In Linked List stack Medium NextGreaterNodeInLinkedList.java

Tree

# Title Solution Difficulty Source Code
94 Binary Tree Inorder Traversal stack or recursive Medium BinaryTreeInorderTraversal.java
95 Unique Binary Search Trees II recursive Medium UniqueBinarySearchTreesII.java
96 Unique Binary Search Trees dp Medium UniqueBinarySearchTrees.java
98 Validate Binary Search Tree recursive or stack Medium ValidateBinarySearchTree.java
100 Same Tree recursive Easy SameTree.java
101 Symmetric Tree recursive Easy SymmetricTree.java
102 Binary Tree Level Order Traversal recursive or bfs by queue Medium BinaryTreeLevelOrderTraversal.java
103 Binary Tree Zigzag Level Order Traversal recursive or bfs by queue Medium BinaryTreeZigzagLevelOrderTraversal.java
104 Maximum Depth of Binary Tree recursive Easy MaximumDepthofBinaryTree.java
105 Construct Binary Tree from Preorder and Inorder Traversal hashmap + recursive Medium ConstructBinaryTreefromPreorderandInorderTraversal.java
106 Construct Binary Tree from Inorder and Postorder Traversal hashmap + recursive Medium ConstructBinaryTreefromInorderandPostorderTraversal.java
107 Binary Tree Level Order Traversal II recursive Easy BinaryTreeLevelOrderTraversalII.java
108 Convert Sorted Array to Binary Search Tree preorder recursive Easy ConvertSortedArraytoBinarySearchTree.java
110 Balanced Binary Tree recursive Easy BalancedBinaryTree.java
111 Minimum Depth of Binary Tree recursive Easy MinimumDepthofBinaryTree.java
112 Path Sum recursive Easy PathSum.java
113 Path Sum II recursive Medium PathSumII.java
114 Flatten Binary Tree to Linked List stack or recursive Medium FlattenBinaryTreetoLinkedList.java
116 Populating Next Right Pointers in Each Node bfs by queue Medium PopulatingNextRightPointersinEachNode.java
117 Populating Next Right Pointers in Each Node II bfs by queue Medium PopulatingNextRightPointersinEachNodeII.java
129 Sum Root to Leaf Numbers stack or recursive Medium SumRoottoLeafNumbers.java
144 Binary Tree Preorder Traversal stack or recursive Medium BinaryTreePreorderTraversal.java
199 Binary Tree Right Side View queue or recursive Medium BinaryTreeRightSideView.java
222 Count Complete Tree Nodes stack or recursive Medium CountCompleteTreeNodes.java
226 Invert Binary Tree stack or recursive Easy InvertBinaryTree.java
230 Kth Smallest Element in a BST stack or recursive Medium KthSmallestElementinaBST.java

Array

# Title Solution Difficulty Source Code

String

# Title Solution Difficulty Source Code

DP

# Title Solution Difficulty Source Code
5 Longest Palindromic Substring dp Medium LongestPalindromicSubstring.java
62 Unique Paths dp Medium UniquePaths.java
63 Unique Paths II dp Medium UniquePathsII.java

Design

# Title Solution Difficulty Source Code
146 LRU Cache HashMap + Double LinkedNode Medium LRUCache.java
155 Min Stack Single LinkedNode or Stack(Java API) easy MinStack.java
173 Binary Search Tree Iterator stack + preorder traversal Medium BinarySearchTreeIterator.java
208 Implement Trie (Prefix Tree) array Medium ImplementTrie.java
211 Add and Search Word - Data structure design Medium AddAndSearchWord.java

Releases

No releases published

Packages

No packages published

Languages