PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates algorithmic reasoning with arrays and the ability to optimize pairwise measurements, specifically assessing understanding of how positional distance and element values combine to maximize an area metric.

  • medium
  • Oracle
  • Coding & Algorithms
  • Software Engineer

Maximize area between vertical lines

Company: Oracle

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given an integer array `h` where `h[i]` represents the height of a vertical line drawn at x-coordinate `i`. Choose **two different indices** `i < j`. Together with the x-axis, these two lines form a container that can hold water. The amount of water the container can hold is: \[ \text{area}(i, j) = (j - i) \times \min(h[i], h[j]) \] Return the **maximum possible area** over all pairs `(i, j)`. ### Input - `h`: array of non-negative integers ### Output - An integer: the maximum area ### Constraints (typical interview constraints) - `2 <= len(h) <= 10^5` - `0 <= h[i] <= 10^4`

Quick Answer: This question evaluates algorithmic reasoning with arrays and the ability to optimize pairwise measurements, specifically assessing understanding of how positional distance and element values combine to maximize an area metric.

Return the maximum area formed by two vertical lines and the x-axis.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,8,6,2,5,4,8,3,7],)

Expected Output: 49

Explanation: Classic example.

Input: ([1,1],)

Expected Output: 1

Explanation: Two lines.

Input: ([0,2,0,3],)

Expected Output: 4

Explanation: Zero heights.

Hints

  1. Pick a representation that makes the requested operation direct.
  2. Handle empty inputs and boundary cases first.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Solve Five Coding Problems - Oracle (medium)
  • Compute letter frequencies from encoded string - Oracle (medium)
  • Count closed islands in a grid - Oracle (easy)
  • Implement in-memory data structures and booking API - Oracle (hard)
  • Return a valid course completion order - Oracle (medium)