Largest Square in a Histogram
Updated
Problem statement
Histogram bars have width one. A square of side k fits when some k consecutive bars each have height at least k.
Return the maximum square area k*k.
Function
largestSquareArea(heights: int[]) → intExamples
Example 1
heights = [1,2,3,3]return = 4Two adjacent bars have height at least two.
Example 2
heights = [3,3,3]return = 9All three bars support a side-three square.
Constraints
1 <= heights.length <= 1000000 <= heights[i] <= 100000
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Index of the Maximum After Left RotationsChubb · OAChubb interview questions
- Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
- Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
- Forward Block Placement QueriesCapital One · OACapital One interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Find Sum of BeautiesAmazon · OA
- Minimum Cost to Attend Required CoursesVisa · OAVisa interview questions