MethodbuildTreeDFS, find root, find range of left and right sub trees The calculation of post array is trivial For left subtree, ps = ps, pe = ps - is - 1 + pos(offs
src/main/java/com/freetymekiyan/algorithms/level/medium/ConstructBTFromInPostOrder.java:19
MethodcanCross2DP, top-down. Recurrence relation: canCross(n, k) denotes whether (n + 1)th stone can be reached with k steps for all k from [0, n-1]: | canCross(n, k
src/main/java/com/freetymekiyan/algorithms/level/hard/FrogJump.java:100
MethodcanWinNimwhen n is 4, no matter you remove 1 or 2 or 3 stones, you always lose suppose n = 4k, always lose when k is k+1, n is 4k+4, which is 4 more stones to
src/main/java/com/freetymekiyan/algorithms/level/easy/NimGame.java:32
MethodcandyO(n) Time, O(n) Space From left to right, if ratings[i] increase, give one more From right to left, if ratings[i] increase, give one more Answer shoul
src/main/java/com/freetymekiyan/algorithms/level/hard/Candy.java:30
MethodconvertToTitleIterative. Map 0 to A, 1 to B, ..., 25 to Z. So we need to decrease n by 1 first. For each iteration, reduce n by 1. Convert n to a character and add
src/main/java/com/freetymekiyan/algorithms/level/easy/ExcelSheetColumnTitle.java:33
MethodcountDigitOnee.g n = 3141592, m = 100, a = 31415, b = 92 hundreds-digit of n is 1 for 3142 times, each has a 100 long streak, (a / 10 100) + 100 when m = 1000, a =
src/main/java/com/freetymekiyan/algorithms/level/hard/NumberOfDigitOne.java:29