Problem · Array
Largest Square Area 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
01 · Example 1
cityline = [1, 2, 3, 2, 1] return = 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.
More Visa problems
public int largetstSquareArea(int[] cityline) {
// write your code here
}
cityline[1, 2, 3, 2, 1]
expected4
checking account