s1 and s2 to act as queues.ans of the same length as nums with all elements set to -1.nums:
a. For each element nums[i], pop elements from s2 while nums[i] is greater than the elements at those indices and set ans for those indices to nums[i].
b. Move elements from s1 to s2 while nums[i] is greater than the elements at those indices in s1.
c. Add the current index i to s1.ans array.