Day 8 Problem

Hello and welcome back brave human being,

Before we dig into the problem, I want to reiterate how interviewing is a skill. The more problems you solve, the more confidence you have.

The candidate who gets the job is the best interviewer, not the smartest.

Given an array of integers, each index represents a line in a container.

Find two lines that together with the x-axis form a container, such that the container contains the most water.

Return the maximum amount of water a container can store.

Let's set an example…

Example

Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49
Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.

Would sorting be a good idea? Or is sorting not required?

Stay tuned for tomorrow’s answer.

JOBS JOBS JOBS

(NEW GRAD)

(INTERN)

Need motivation to be consistent?

Add this problem to your log and when the challenge is done send it to me! You’ll be in for a treat.

Reply

or to participate.