Company: Ziprecruiter
Difficulty: medium
Largest Square Area in Cityline 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. Example For cityLine = [1, 2, 3, 2, 1] , the output should be 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. For cityLine = [4, 3, 4] , the output should be 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. Input Format An array cityLine representing the heights of the skyscrapers. Each skyscraper