Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/FreeTymeKiyan/LeetCode-Sol-Res
/ functions
Functions
1,974 in github.com/FreeTymeKiyan/LeetCode-Sol-Res
⨍
Functions
1,974
◇
Types & classes
889
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/MinimumSwapsToMakeSequencesIncreasingTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/SortColorsTest.java:10
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/NumberOfCornerRectanglesTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/IsGraphBipartiteTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/WordLadderTest.java:12
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/BestTimeStockTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/NumberOfIslandsTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/HIndex2Test.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/ArithmeticSlicesTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeInOrderTraversalTest.java:13
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/WallsAndGatesTest.java:10
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/WordBreakTest.java:12
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/SubArraySumEqualsKTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/LongestIncreasingSubsequenceTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/IncreasingTripletSubsequenceTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/ProductofArrayExceptSelfTest.java:10
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/LowestCommonAncestorOfABinaryTreeTest.java:11
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/WordSearchTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/GraphValidTreeTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/StrobogrammaticNumber2Test.java:14
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/PermutationInStringTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/medium/SqrtTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/StrobogrammaticNumberTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/ValidWordAbbreviationTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/AddBinaryTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/RomanToIntegerTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/FirstUniqueCharacterInAStringTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/MoveZeroesTest.java:11
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/ValidParenthesesTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/ValidPalindromeTest.java:9
Method
getExamples
()
src/test/java/com/freetymekiyan/algorithms/level/easy/ValidPalindrome2Test.java:12
Method
getFactors
Backtracking. Factors are from 2 to sqrt(n), inclusive.
src/main/java/com/freetymekiyan/algorithms/level/medium/FactorCombinations.java:54
Method
getHint
Use an array of 10 digits as a simple table. We can get # of bulls by comparing digits one by one. If they are the same, # of bulls increase by 1. Oth
src/main/java/com/freetymekiyan/algorithms/level/easy/BullsAndCows.java:41
Method
getHits
Return the number of hits in the past 5 minutes. @param timestamp - The current timestamp (in seconds granularity).
src/main/java/com/freetymekiyan/algorithms/level/medium/DesignHitCounter.java:79
Method
getInteger
()
src/main/java/com/freetymekiyan/algorithms/utils/Utils.java:146
Method
getInteger
()
src/main/java/com/freetymekiyan/algorithms/level/medium/MiniParser.java:127
Method
getIntersectionNode
Time O(n), Space O(1) skip all impossible ones use recursion to compare next one
src/main/java/com/freetymekiyan/algorithms/level/easy/IntersectionOfTwoLinkedLists.java:32
Method
getIntervals
Get intervals list directly from the map's value collection. O(1) Time.
src/main/java/com/freetymekiyan/algorithms/level/hard/DataStreamAsDisjointIntervals.java:89
Method
getIntervals
In-order traversal on the BST. O(n) Time.
src/main/java/com/freetymekiyan/algorithms/level/hard/DataStreamAsDisjointIntervals.java:154
Method
getInvalidInput
()
src/test/java/com/freetymekiyan/algorithms/level/easy/FirstUniqueCharacterInAStringTest.java:27
Method
getList
()
src/main/java/com/freetymekiyan/algorithms/utils/Utils.java:150
Method
getList
()
src/main/java/com/freetymekiyan/algorithms/level/medium/MiniParser.java:143
Method
getMapKey
(String word)
src/main/java/com/freetymekiyan/algorithms/level/medium/GroupAnagrams.java:60
Method
getMin
Peek min stack to get current minimum.
src/main/java/com/freetymekiyan/algorithms/level/easy/MinStack.java:53
Method
getMin
()
src/main/java/com/freetymekiyan/algorithms/level/easy/MinStack.java:81
Method
getModifiedArray
Instead of update all values in the range, we update the start index with the value. And the index after end index with negative value. (Safely ignore
src/main/java/com/freetymekiyan/algorithms/level/medium/RangeAddition.java:62
Method
getMoneyAmount
DP, top-down. Minimize the maximum of each possible move. The maximum here means the move will always lead to the worst branch. For each move, you can
src/main/java/com/freetymekiyan/algorithms/level/medium/GuessNumberHigherOrLower2.java:58
Method
getMoneyAmountB
DP, bottom-up. Build result of i from 1 to n. For each number, get the global min of j from i - 1 to 1. To get the global min, calculate the local max
src/main/java/com/freetymekiyan/algorithms/level/medium/GuessNumberHigherOrLower2.java:86
Method
getNewsFeed
(int userId)
src/main/java/com/freetymekiyan/algorithms/level/medium/DesignTwitter.java:68
Method
getNumberOfOnes
(int[] topLeft, int[] bottomRight)
src/main/java/com/freetymekiyan/algorithms/other/GetNumberOfOnes.java:35
Method
getPermutationB
Divide into subgroups and locate it
src/main/java/com/freetymekiyan/algorithms/level/medium/PermutationSequence.java:69
Method
getRandom
Get a random element from the collection.
src/main/java/com/freetymekiyan/algorithms/level/hard/InsertDeleteGetRandomDuplicatesAllowed.java:93
Method
getRandom
Get a random element from the set. Just generate a random index.
src/main/java/com/freetymekiyan/algorithms/level/medium/InsertDeleteGetRandom.java:111
Method
getRandom
Returns a random node's value.
src/main/java/com/freetymekiyan/algorithms/level/medium/LinkedListRandomNode.java:59
Method
getRangeSum
Get range sum, inclusive
src/main/java/com/freetymekiyan/datastructures/BinaryIndexedTree.java:64
Method
getRow
(int rowIndex)
src/main/java/com/freetymekiyan/algorithms/level/easy/PascalsTriangle2.java:31
Method
getSkyline
My own implementation with max heap. The candidates are sorted by x asc, y desc. For each candidate point: | If it's a left point, it's a start of a s
src/main/java/com/freetymekiyan/algorithms/level/hard/TheSkylineProblem.java:66
Method
getSkyline2
Heap. Line Sweep Algorithm. All possible key points are at the edges of rectangle. Add all top-left and top-right corners to a list. Set top-left's he
src/main/java/com/freetymekiyan/algorithms/level/hard/TheSkylineProblem.java:122
Method
getSum
For example, a = 0001, b = 0011. First, we can use "and"("&") operation between a and b to find a carry. carry = a & b, then carry = 0001 Second, we c
src/main/java/com/freetymekiyan/algorithms/level/easy/SumOfTwoIntegers.java:24
Method
getSumRecursive
(int a, int b)
src/main/java/com/freetymekiyan/algorithms/level/easy/SumOfTwoIntegers.java:36
Method
getTreeDiameter
(TreeNode root)
src/main/java/com/freetymekiyan/algorithms/other/TreeDiameter.java:8
Method
getTreeHeight
get the height of the tree if it is balanced return -1 if it is not balanced
src/main/cpp/110_Balanced_Binary_Tree.cpp:33
Method
greater
(int i, int k)
src/main/java/com/freetymekiyan/datastructures/MaxPQ.java:83
Method
groupAnagrams
Hash Table. Use sorted word as the key, since all anagrams share the same sorted form. Then same anagrams form a list as the value. For each word, sor
src/main/java/com/freetymekiyan/algorithms/level/medium/GroupAnagrams.java:38
Method
groupStrings
(String[] strings)
src/main/java/com/freetymekiyan/algorithms/level/medium/GroupShiftedStrings.java:38
Method
hIndex
We actually want to know how many papers are there with >= some h. Given an h, we can query some data structure to achieve that. Let's assume there is
src/main/java/com/freetymekiyan/algorithms/level/medium/HIndex.java:45
Method
hammingDistance
Bit Manipulation. By def., hamming distance is the number of positions where the corresponding bits are different. XOR can generate a result where dif
src/main/java/com/freetymekiyan/algorithms/level/easy/HammingDistance.java:40
Method
hasCycle
Runnner's technique Check the next and next next of faster node is slower node or not.
src/main/java/com/freetymekiyan/algorithms/level/medium/LinkedListCycle.java:21
Method
hasLeader
Traverse the list Update leader index if leader is friend of current id Then check if leader is real with one more traversal
src/main/java/com/freetymekiyan/algorithms/other/Celebrity.java:19
Method
hasNext
@return whether we have a next smallest number */
src/main/cpp/173_Binary_Search_Tree_Iterator.cpp:51
Method
hasNext
()
src/main/java/com/freetymekiyan/datastructures/LinkedListBag.java:26
Method
hasNext
()
src/main/java/com/freetymekiyan/datastructures/ArrayStack.java:112
Method
hasNext
If the stack is empty, there is no more node left.
src/main/java/com/freetymekiyan/algorithms/level/medium/BinarySearchTreeIterator.java:39
Method
hasNext
@return whether we have a next smallest number
src/main/java/com/freetymekiyan/algorithms/level/medium/BSTIterator.java:38
Method
hasPathSum
Substract root value from sum every time Return leaf node with sum == 0 Or result in left subtree or right subtree
src/main/java/com/freetymekiyan/algorithms/level/easy/PathSum.java:28
Method
hit
Record a hit. @param timestamp - The current timestamp (in seconds granularity).
src/main/java/com/freetymekiyan/algorithms/level/medium/DesignHitCounter.java:64
Method
inorderSuccessor
Tree. Recursive. In BST, root is the largest of left subtree, smallest of right subtree. In-order successor is the smallest of all node's larger than
src/main/java/com/freetymekiyan/algorithms/level/medium/InorderSuccessorInBST.java:31
Method
inorderSuccessor2
Tree. Iterative. Quick check on the right subtree. | If there is a right subtree, just return the leftmost child of right subtree. If it does NOT have
src/main/java/com/freetymekiyan/algorithms/level/medium/InorderSuccessorInBST.java:52
Method
inorderTraversal
src/main/cpp/094_Binary_Tree_Inorder_Traversal.cpp:34
Method
insert
(Key v)
src/main/java/com/freetymekiyan/datastructures/MaxPQ.java:34
Method
insert
Inserts a value to the collection. Returns true if the collection did not already contain the specified element.
src/main/java/com/freetymekiyan/algorithms/level/hard/InsertDeleteGetRandomDuplicatesAllowed.java:65
Method
insert
Inserts a value to the set. Returns true if the set did not already contain the specified element. Check if the value exists. If yes, return false. If
src/main/java/com/freetymekiyan/algorithms/level/medium/InsertDeleteGetRandom.java:79
Method
insertB
Array. Sort. Not in place solution. O(n) Time. Make use of intervals are sorted. Create a result list of intervals, res. Add new interval to res first
src/main/java/com/freetymekiyan/algorithms/level/hard/InsertInterval.java:64
Method
insertionSortList
src/main/cpp/147_Insertion_Sort_List.cpp:22
Method
insertionSortList
Check the list one by one to find a node that has smaller value than nodes before it and swap
src/main/java/com/freetymekiyan/algorithms/level/medium/InsertionSortList.java:14
Method
intToRoman
Recursion. <p> Base case: If the integer is less than 1, which means there's no roman equivalent, then return empty string. <p> Recurrence relation: T
src/main/java/com/freetymekiyan/algorithms/level/medium/IntToRoman.java:29
Method
intToRoman2
While loop. <p> Go through the dict, if num >= INTEGERS[i], append roman integer num -= INTEGERS[i] if num < INTEGERS[i], i++
src/main/java/com/freetymekiyan/algorithms/level/medium/IntToRoman.java:45
Method
integerBreak
Math. If factor x >= 4, we can decompose it into 2 and (x-2), 2 (x-2)= 2x - 4 > x. So the final product will be larger, means that the product won't e
src/main/java/com/freetymekiyan/algorithms/level/medium/IntegerBreak.java:27
Method
integerReplacement
(int n)
src/main/java/com/freetymekiyan/algorithms/level/medium/IntegerReplacement.java:41
Method
integerReplacement2
(int n)
src/main/java/com/freetymekiyan/algorithms/level/medium/IntegerReplacement.java:56
Method
intersect
Use a hash map to record count of each integer in one array. Then go through the other array to find intersection. Count should be updated when an int
src/main/java/com/freetymekiyan/algorithms/level/easy/IntersectionofTwoArrays2.java:37
Method
intersectJava8
(int[] nums1, int[] nums2)
src/main/java/com/freetymekiyan/algorithms/level/easy/IntersectionofTwoArrays2.java:58
Method
intersection
Two hash sets. One hash set for one array. The other for the intersection.
src/main/java/com/freetymekiyan/algorithms/level/easy/IntersectionofTwoArrays.java:29
Method
intersectionJava8
Java 8 stream. Convert one of the arrays to set using collect. Then generate a distinct filtered stream from the other array.
src/main/java/com/freetymekiyan/algorithms/level/easy/IntersectionofTwoArrays.java:55
Method
isAdditiveNumber
(String num)
src/main/java/com/freetymekiyan/algorithms/level/medium/AddtiveNumber.java:41
Method
isBalanced
src/main/cpp/110_Balanced_Binary_Tree.cpp:56
Method
isBalanced
(TreeNode root)
src/main/java/com/freetymekiyan/algorithms/level/easy/BalancedBinaryTree.java:18
Method
isConnected
Check whether two points are in the same edges component. If connected, they will have the same id.
src/main/java/com/freetymekiyan/algorithms/level/medium/NumberOfIslands.java:229
Method
isEmpty
()
src/main/java/com/freetymekiyan/datastructures/LinkedListStack.java:48
Method
isInteger
()
src/main/java/com/freetymekiyan/algorithms/utils/Utils.java:142
← previous
next →
1,101–1,200 of 1,974, ranked by callers