FastPrepFastPrep
Problem Brief

Largest Square Area in Cityscape

OA

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.

1Example 1

Input
cityline = [1, 2, 3, 2, 1]
Output
4
Explanation
Example 1 illustration
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.
public int largetstSquareArea(int[] cityline) {
  // write your code here
}
Input

cityline

[1, 2, 3, 2, 1]

Output

4

Sign in to submit your solution.