I do not understand arr[s.top()]

s.top() function gives the value of the top element right ?
than what is the need of the arr[s.top()], what it will give us ?

hello @premang
no ,
stk.top() will give u index and arr[stk.stop()] will give u value present at that index.
pls refer this ->

1 Like

got ittttttttttttttttt :wink: