Currently practicing: NeetCode Blind 75
- For tree problems, recursive DFS is cleanest to implement.
Make a map of item and index. Check if target - currentItem exists.
Create a set and put items in one by one while checking if `num` is already there.
compare the count of letters in each word and put group them in a map
count all numbers. sort. and return top k. Use streams to make it cleaner. or use bucket sort.
check if the length is the same.
find the difference in the count of letters in both numbers.
since there are only 26 letters, you can count in a single int array of 26.
index = char - 'a'
first right to left while multiplying.
Then second left to right while multiplying.
This can be done in a single array and one extra product variable
Have 2 pointers. One at the start other at the end. Skip if `!Character.isLetterOrDigit` and compare with `Character.toLowerCase`
God-level solution - iterate.
If an opening bracket is found, put the closing bracket in a stack.
If the closing bracket is found, pop and check for equality.
Make sure the left pointer is always the lowest yet. Keep checking the difference between left and right. And return max.
Swap left and right. Then repeat for those nodes.
Have a fast pointer and a slow pointer. fast increases by 2. slow increases by 1. if both become the same then the cycle exists. if fast one reaches end then no cycle exists.
go to each depth, incrementing a depth counter by 1. return max of it.
Iterate over both and store minimum one in current; Increment in the list from where minimum came. Once one of the lists is empty, empty the other one.
Similar to swapping two numbers. Start with prev as null and current and keep swapping next. Return prev because that's the last value.
Check if root is same as subtree or root.left is same or root.right is same;
Check if the last bit is 1 by (n&1). Do the right unsigned shift (logical shift >>>). Loop.
Get the last bit of value from the original. append to the reverse one. shift reverse one to the left. instead of adding, you can do `or` because after the shift last value will be 0. Imp - iterate 32 times only.