Company: Uber
Difficulty: medium
Largest Square in Cityscape You are tasked with analyzing the potential space in a cityscape outlined by a series of skyscrapers. Each skyscraper\'s height is represented by an element in the array cityLine , where the width of each skyscraper is consistently 1 , and they are placed directly adjacent to each other along a road with no gaps. Your mission is to determine the largest square area that can fit within this row of skyscrapers. Examples Input: cityLine = [1, 2, 3, 2, 1] Output: solution(cityLine) = 4 In this configuration, there are several 2x2 squares that can be accommodated within the skyscrapers, but no larger square can fit owing to the limitations of their heights. Input: cityLine = [4, 3, 4] Output: solution(cityLine) = 9 In this scenario, a 3x3 square can fit snugly within the skyscraper setup, taking advantage of the uniform heights at the edges.