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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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 24 times
Sample Input 55 62 70 28 62 92 1 5 3 4 2 Sample output 2 -1 4 -1 -1
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply