Walmart Coding Question – Solved

7 Live
Will We Meet In the bustling town of Skyline Street, Jatin and Mano, two childhood friends, often challenge each other to exciting games. One day, they came up with a unique adventure-"The Climb of Heights." Skyline Street consists of N buildings, each with a unique height, forming a magnificent skyline. The friends decide to start from their respective buildings and see if they can meet on a taller building by following a simple rule: They can only move to the right (towards buildings with greater heights than their current one). Once they reach a taller building, they continue the journey until no taller building exists in front of them. Excited by the challenge, they come to you, the town's wise strategist, to predict their meeting point. Given a list H representing the heights of the buildings and multiple queries where Jatin and Mano start from different buildings, your task is to determine the leftmost building where they can meet. If no such meeting point exists, return -1. Can you help Jatin and Mano navigate their way through Skyline Street and find out if they can meet atop a grand building? |Input Format The first line of input contains two integers N and 'O' representing the number of buildings in the city and 'O' the number of queries. The second line of input contains N space-separated integers representing the heights of the buildings. The next Q lines of input contain 2 space-separated integers J and M representing the starting positions of Jatin and Mano.

Asked in: Walmart

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |