Author: Shivam Garg DIFFICULTYEASY PREREQUISITESBasic Knowledge of Sets (STL) PROBLEMGiven a list of integers, for each of them find the maximum number less than the given number preceding it. EXPLANATIONThe brute approach will turn out to be of complexity $O(N ^2)$, and hence is bound to time out. We can maintain a sorted set of numbers by iterating over the array. In other words, if we have a set of numbers preceding the given number, we can easily find out the largest number smaller than the given number. We can simply perform binary search in this set to find the number just less than the given number.
This will fulfill our task. The complexity of accessing/inserting elements in the set is $O(Log(N))$. SOLUTIONSetter's Solution  Code asked 13 Feb '18, 23:58

your explanation is not clear bro(#no offence) if u can then add little more details for the approach thx in advance : ) answered 31 May '18, 00:22
