if an array is 1 23 44 13 89 then the output will be
23 44 44 89 89 89 89 89 right? till it reaches the last index after one round right?
Doubt in the question
okay mtlb after comparing 13 and 89 we will compare 89 and 1 and then we won’t compare 89 with 23 right?
@aryaman.kumar26 we just have to compare till last start from that index.
for 89 its already the last so -1
okay so if we don’t find bigger element than 89 as given int he example then the answer should 23 44 44 89 -1 as there is no bigger number than 89 right?
well the answer should be 23 44 -1 89 -1 right?
so its a sliding window concept right?
sir there is 13 in between 44 and 89
better can be done using vector. but it as vector doubles its space therefore not good for large number of elements right?
@aryaman.kumar26 you have to find next greater element till the end if found
Ex 3 1 2 1 4
So ans
4 2 4 4 -1