Back to problems

Largest Square Area in Cityscape

Algorithm · Visa · Medium

You are given an array cityline that represents a row of adjacent skyscrapers. Each integer in the array is the height of a skyscraper, and every skyscraper has a width of exactly 1. The buildings sit side by side with no gaps between them. Your task is to find the area of the largest square that can be placed entirely within the bounds of this skyline. The square must be axis-aligned and its base must rest on the ground (height 0). Examples Example 1 Explanation: The…

Checking your access…