K Empty Slots – Java

Time O(nlogn)
Space O(n)

Top K Frequent Elements – Java

Runtime O(nlogn)

Continue reading “Top K Frequent Elements – Java”

Reverse Words in a String – Java

Using a Stack
Uses O(n) memory and time.

Continue reading “Reverse Words in a String – Java”

Generate Paranthesis – Java


Sort Array by Parity – Java

This solution runs in 0(n) time (linear) and uses O(1) space (constant) and is based on the Dutch National Flag Problem.