Company: Nokia_23march
Difficulty: medium
Skyscapers Problem Description A city planner oversees a stretch of parkland running from position 0 to K. Over time, the city puts up N buildings one at a time at specific locations within this stretch. After each building goes up, the planner wants to know the length of the longest unbroken stretch of parkland that remains, and record that value. Checking this after every single building is tedious, though, so the planner instead poses Q questions to you, each one asking for the longest unbroken parkland stretch immediately after the query[i] th building has gone up. Help answer these correctly. Your task is to answer all the queries efficiently, returning an array whose entries give the longest unbroken parkland stretch for each corresponding query. Task Return an array where the P th element is the length of the longest unbroken parkland stretch immediately after the query[P] th building has gone up. Function description Complete the function solve() provided in the editor. This fu