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
testPositiveNumbers
()
src/main/java/com/freetymekiyan/algorithms/level/easy/ConvertANumberToHexadecimal.java:77
Method
testProductExceptSelf
(int[] input, int[] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/ProductofArrayExceptSelfTest.java:20
Method
testProductExceptSelf2
(int[] input, int[] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/ProductofArrayExceptSelfTest.java:26
Method
testRomanToInt
(String romans, int expected)
src/test/java/com/freetymekiyan/algorithms/level/easy/RomanToIntegerTest.java:18
Method
testSearch
()
src/test/java/com/freetymekiyan/algorithms/level/hard/SearchInRotatedSortedArrayTest.java:12
Method
testSearch
()
src/test/java/com/freetymekiyan/algorithms/level/medium/ImplementTrieTest.java:34
Method
testSearch2
()
src/test/java/com/freetymekiyan/algorithms/level/hard/SearchInRotatedSortedArrayTest.java:18
Method
testSimplifyPath
()
src/test/java/com/freetymekiyan/algorithms/level/medium/SimplifyPathTest.java:8
Method
testSingleElementInput
()
src/test/java/com/freetymekiyan/algorithms/level/easy/LongestContinuousIncreasingSubsequenceTest.java:45
Method
testSortColors
(int[] input, int[] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/SortColorsTest.java:21
Method
testSortColors2
(int[] input, int[] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/SortColorsTest.java:28
Method
testSortColors3
(int[] input, int[] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/SortColorsTest.java:35
Method
testSortColors4
(int[] input, int[] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/SortColorsTest.java:42
Method
testSpecialPrices
()
src/test/java/com/freetymekiyan/algorithms/level/medium/BestTimeToBuyAndSellStockWithTransactionFeeTest.java:16
Method
testStartsWith
()
src/test/java/com/freetymekiyan/algorithms/level/medium/ImplementTrieTest.java:18
Method
testStrStr
()
src/test/java/com/freetymekiyan/algorithms/level/easy/ImplementStrStrTest.java:8
Method
testStrobogrammaticInRange
()
src/test/java/com/freetymekiyan/algorithms/level/hard/StrobogrammaticNumber3Test.java:10
Method
testSubarraySum
(int[] nums, int k, int expected)
src/test/java/com/freetymekiyan/algorithms/level/medium/SubArraySumEqualsKTest.java:18
Method
testThreeSumReuseOnce
()
src/test/java/com/freetymekiyan/algorithms/other/ThreeSumReuseOnceTest.java:11
Method
testTotalNumberOfSeconds
(List<int[]> events, int expected)
src/test/java/com/freetymekiyan/algorithms/other/TotalNumberOfSecondsTest.java:21
Method
testTwoSum
()
src/test/java/com/freetymekiyan/algorithms/level/easy/TwoSumTest.java:8
Method
testUpdateValue
()
src/test/java/com/freetymekiyan/algorithms/other/UpdateTreeValueTest.java:8
Method
testValidPalindromeExamples
(String s, boolean expected)
src/test/java/com/freetymekiyan/algorithms/level/easy/ValidPalindrome2Test.java:25
Method
testValidTree
(int n, int[][] edges, boolean output)
src/test/java/com/freetymekiyan/algorithms/level/medium/GraphValidTreeTest.java:18
Method
testValidWordAbbreviation
(String word, String abbr, boolean expected)
src/test/java/com/freetymekiyan/algorithms/level/easy/ValidWordAbbreviationTest.java:21
Method
testWallsAndGates
(int[][] input, int[][] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/WallsAndGatesTest.java:29
Method
testWallsAndGates2
(int[][] input, int[][] output)
src/test/java/com/freetymekiyan/algorithms/level/medium/WallsAndGatesTest.java:36
Method
testWithDup
()
src/main/java/com/freetymekiyan/algorithms/other/UserSessions.java:76
Method
testWithExamples
()
src/main/java/com/freetymekiyan/algorithms/level/easy/HouseRobber.java:91
Method
testWithExamples
()
src/main/java/com/freetymekiyan/algorithms/level/easy/ReverseVowelsOfAString.java:66
Method
testWithoutDup
()
src/main/java/com/freetymekiyan/algorithms/other/UserSessions.java:65
Method
testWordBreak
(String s, List<String> words, boolean output)
src/test/java/com/freetymekiyan/algorithms/level/medium/WordBreakTest.java:64
Method
testWordBreak2
(String s, List<String> words, boolean output)
src/test/java/com/freetymekiyan/algorithms/level/medium/WordBreakTest.java:70
Method
testWordFilterExample
()
src/test/java/com/freetymekiyan/algorithms/level/hard/PrefixAndSuffixSearchTest.java:8
Method
threeSum
Two Pointers. Sort given array first. Traverse the array with 1 pointer. Use another 2 pointers from both start(i + 1) and end to find the target. How
src/main/java/com/freetymekiyan/algorithms/level/medium/ThreeSum.java:37
Method
threeSum2
Two pointers. More concise. Compare first, then move pointer to skip all duplicates. Note that it compares current position with the next position. So
src/main/java/com/freetymekiyan/algorithms/level/medium/ThreeSum.java:84
Method
threeSumClosest
Sort and initialize min use two pointers to manipulate sums update min when closer return when min equals to target or all done
src/main/java/com/freetymekiyan/algorithms/level/medium/ThreeSumClosest.java:23
Method
top
()
src/main/java/com/freetymekiyan/algorithms/level/easy/MinStack.java:77
Method
top
()
src/main/java/com/freetymekiyan/algorithms/level/easy/ImplementStackUsingQueues.java:50
Method
totalHammingDistance
Count each bit in the 32-bit ints how many 1s, a and 0s, b. The total hamming distance of this bit is then a b. Go through all the 32-bit to get total
src/main/java/com/freetymekiyan/algorithms/level/medium/TotalHammingDistance.java:33
Method
trailingZeroes
src/main/cpp/172_Factorial_Trailing_Zeroes.cpp:18
Method
trailingZeroesB
Recursive
src/main/java/com/freetymekiyan/algorithms/level/easy/FactorialTrailingZeroes.java:31
Method
transform
find all possible transformations of word in wordList
src/main/cpp/126_Word_Ladder_II.cpp:42
Method
trap
src/main/cpp/042_Trapping_Rain_Water.cpp:65
Method
trap
Water will need a "container" to be trapped. A "container" will need borders or boundaries. Keep track of the lowest boundary. <p> Calculate the area
src/main/java/com/freetymekiyan/algorithms/level/hard/TrappingRainWater.java:38
Method
trap2
Two pointers. <p> Water can be trapped if: The minimum border height is larger than possible water level. Get the current level from the two pointers.
src/main/java/com/freetymekiyan/algorithms/level/hard/TrappingRainWater.java:73
Method
trapRainWater
Heap. <p> Water needs a container to be trapped. A container is formed by surrounding borders. The borders of the matrix can't hold water, they are in
src/main/java/com/freetymekiyan/algorithms/level/hard/TrappingRainWater2.java:54
Method
twoSum
Two pointers. Use two indices from both ends of the array and compare sum with target. If target is larger, move the end index. If target is smaller,
src/main/java/com/freetymekiyan/algorithms/level/medium/TwoSum2.java:27
Method
unfollow
(int followerId, int followeeId)
src/main/java/com/freetymekiyan/algorithms/level/medium/DesignTwitter.java:84
Method
union
(int p, int q)
src/main/java/com/freetymekiyan/algorithms/other/QuickUnionUF.java:24
Method
uniquePaths
src/main/cpp/062_Unique_Paths.cpp:34
Method
uniquePaths
src/main/cpp/062_Unique_Paths.cpp:63
Method
uniquePaths
src/main/cpp/062_Unique_Paths.cpp:90
Method
uniquePaths
DP, bottom-up approach
src/main/java/com/freetymekiyan/algorithms/level/medium/UniquePaths.java:59
Method
uniquePathsWithObstacles
src/main/cpp/063_Unique_Paths_II.cpp:35
Method
uniquePathsWithObstacles
src/main/cpp/063_Unique_Paths_II.cpp:71
Method
upsideDownBinaryTree
Recursive. Observations: Leftmost child becomes the new root, suppose it's parent is p. p's right child becomes the new root's left. p itself becomes
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeUpsideDown.java:49
Method
upsideDownBinaryTreeB
Iterative. All right subtrees only have 1 node. Move down along the left children. While current node is not null: | Store the next left child. | Set
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeUpsideDown.java:73
Method
validUtf8B
Math. Check how many bytes with number range. 1) 1 byte, [0, 127] 2) 2 bytes, [192, 223] 3) 3, [224, 239] 4) 4, [240, 247] 5) If out of these ranges,
src/main/java/com/freetymekiyan/algorithms/level/medium/Utf8Validation.java:89
Method
verifyPreorder
(int[] preorder)
src/main/java/com/freetymekiyan/algorithms/level/medium/VerifyPreorderSequenceInBinarySearchTree.java:38
Method
verifyPreorder2
(int[] preorder)
src/main/java/com/freetymekiyan/algorithms/level/medium/VerifyPreorderSequenceInBinarySearchTree.java:51
Method
verticalOrder
BFS, Hash Table. <p> Vertical traversal is viewing a tree from left to right, from top to bottom. Divide the tree nodes into rows and columns, like a
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeVerticalOrderTraversal.java:101
Method
wiggleSort
Swap neighbors A0 >= A1 <= A2 >= A3 .... .... An.
src/main/java/com/freetymekiyan/algorithms/other/WiggleSort.java:20
Method
wiggleSort
Quick select + Three-way partition. Find the median with quick select. Then put smaller ones on even indices. Put larger ones on odd indices. https://
src/main/java/com/freetymekiyan/algorithms/level/medium/WiggleSort2.java:36
Method
wiggleSort
The final sorted nums needs to satisfy two conditions: <p> If i is odd, then nums[i] >= nums[i - 1]; If i is even, then nums[i] <= nums[i - 1]. <p> Pr
src/main/java/com/freetymekiyan/algorithms/level/medium/WiggleSort.java:25
Method
wiggleSort2
A0 <= A1 >= A2 <= A3 .... .... An.
src/main/java/com/freetymekiyan/algorithms/other/WiggleSort.java:30
Method
wiggleSortB
Same idea, just a more concise version.
src/main/java/com/freetymekiyan/algorithms/level/medium/WiggleSort.java:46
Method
wordBreak
DP, Backtracking Store successful decomposition in a map Get prefix If not in dictionary, just ignore If in dictionary, check current position If reac
src/main/java/com/freetymekiyan/algorithms/level/hard/WordBreak2.java:44
Method
wordBreakB
Backtracking Get prefix first If prefix is in dictionary, check current length If reaches the end, add prefix to result If not, go ahead and decompose
src/main/java/com/freetymekiyan/algorithms/level/hard/WordBreak2.java:79
Method
wordPatternMatch2
(String pattern, String str)
src/main/java/com/freetymekiyan/algorithms/level/hard/WordPattern2.java:61
Method
zigzagLevelOrder
BFS. Use a boolean to indicate different level order. Toggle it after a level is finished.
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeZigzagLevelOrderTraversal.java:39
Method
zigzagLevelOrder
Use queue to do BFS. Get queue's size to get nodes in each level. Use a boolean to indicate difference level order. Toggle it after a level is finishe
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeZigZag.java:43
Method
zigzagLevelOrder2
Use two lists, one for cur level, one for next level Use a binary flag to determin whether we toggle the order of current level or not Update flag aft
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeZigZag.java:71
Method
zigzagLevelOrderB
DFS. Backtrack. For current node, first check whether we have enough levels in result. If not enough, add a new empty list. Then add to the relative l
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeZigzagLevelOrderTraversal.java:78
← previous
1,901–1,974 of 1,974, ranked by callers