FastPrepLargest Square in a Histogram
Problems/Largest Square in a Histogram

Largest Square in a Histogram

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes width-one bars, the rule of k consecutive heights that are at least k, the maximum area, and examples returning 4, 9, and 1. We supplied limits and a function signature.

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[]) → int

Examples

Example 1

heights = [1,2,3,3]return = 4

Two adjacent bars have height at least two.

Example 2

heights = [3,3,3]return = 9

All three bars support a side-three square.

Constraints

  • 1 <= heights.length <= 100000
  • 0 <= 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

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int largestSquareArea(int[] heights) {
        // Write your code here.
    }

}
Checking account…