To see the question, click here.
Naive Approach
The idea is to store the elements in a list. At each stage of adding an element, we will sort the list because the elements may not be added to the list in a sorted fashion.
// TC: O(nlogn) for addNum a...