Storing my solutions for Leetcode
A string a
is lexicographically smaller than a string b
if in the first position where a
and b
differ, string a
has a letter that appears earlier in the alphabet than the corresponding letter in b
.
If the first min(a.length, b.length)
characters do not differ, then the shorter string is the lexicographically smaller one.
A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one.
It means that the values in the stack are either increasing/decreasing/equal in order.
- If s1 + s2 = s2 + s1, there exists a substring
x
in both s1 and s2 wherex
dividess1
ands2
- A string
x
dividesy
if and only ify = x + ... + x
- TODO: find a good explanation
- Find duplicate number in linked listed (FindDuplicateNumber.java)
https://www.geeksforgeeks.org/java-util-arrays-copyofrange-java/
- Lowercase strings -> consider using new int[26] to store frequency of characters
- Save the result outside of the function
- Need a temp stack for the result when backtracking
- usually call another function(backtrack) to initialise the DP
- Usually when question looks for kth...., we use heaps
- If question requies O(1) and its an array of integers, usually its two pointers or bit manipulation