Page 1 of 1

Please using stack data structure to solve this problem You are given an array A of Q integers and Q queries. In each qu

Posted: Mon Jun 06, 2022 4:29 pm
by answerhappygod
Please using stack data structure to solve this
problem
You are given an array A of Q integers and Q queries. In each
query, you are given an integer (1<=i<=N). Your task is to
find the minimum index greater than i (1<=i<=N) such
that:
If there is no answer, then
print -1.
Input format
Constraints:
(1<=N, Q<=1000)
(1<= Ai <=1000)
(1<=Qi<=N)
Output format: print the answer as described in the problem.
Please Using Stack Data Structure To Solve This Problem You Are Given An Array A Of Q Integers And Q Queries In Each Qu 1
Please Using Stack Data Structure To Solve This Problem You Are Given An Array A Of Q Integers And Q Queries In Each Qu 1 (9.42 KiB) Viewed 25 times
Sample Input 55 62 70 28 62 92 1 5 3 4 2 Sample output 2 -1 4 -1 -1