Master Data Structures & Algorithms For FREE at AlgoMap.io!
@JoeTan-nq4fq2 ай бұрын
Being OCD, to reduce the computational time, we can do the height check and compute the area in the same conditional (instead of adding min(height[l], height[r] which add n runtime). if height[left] < height[right]: area = height[left] * (right - left) left += 1 else: area = height[right] * (right - left) right -= 1 maxx = max(maxx, area)
@anna-plink4 ай бұрын
No way this was more difficult than 3Sum 🤔
@user-jm6gp2qc8x3 ай бұрын
he sets you up for a harder problem just right after this one, its a trap XD
@rodneyshen73973 ай бұрын
I was legit thinking the exact same thing haha.
@ruixue69552 ай бұрын
1:39 2:22 how to move cursor 2:46 which bar to keep
@sreekanthpogula271410 ай бұрын
Great greg 👍, I just solved this yesterday
@GregHogg10 ай бұрын
That's great!
@coopernik10 ай бұрын
very well explained
@dibyendusaha12952 ай бұрын
golang solution: import ( "math" ) func maxArea(height []int) int { left := 0 right := len(height)-1 maxArea:=0 for left
@pauldaly1yt10 ай бұрын
How long would one typically get to prepare a solution to a problem like this in an interview?
@brianwkinyua3 ай бұрын
I hear around 45 minutes.
@rijulranjan85142 ай бұрын
Nowadays not 45 mins. This is on the easier side interviewers would probably expect like 15-20 mins