Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a function to find the largest rectangle area in a histogram.

Medium

Problem Statement

Implement a function to find the largest rectangle area in a histogram.

Sample Input

Histogram heights: [2, 1, 5, 6, 2, 3]

Sample Output

Largest rectangle area: 10

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun largestRectangleArea(heights: Array<Int>): Int { // Add your code here to find the largest rectangle area } fun main() { val heights = arrayOf(2, 1, 5, 6, 2, 3) println("Largest rectangle area: ${largestRectangleArea(heights)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
Histogram heights: [2, 1, 5, 6, 2, 3]
Expected Output
Largest rectangle area: 10