Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
It's not clear from the problem statement that the capital array will always be ...

Micky M

Jul 8, 2022

It's not clear from the problem statement that the capital array will always be a sequence of array indices [1,2,3,4,5...], as the solution suggests that it is. The problem statement could be more explicit.

2

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

The capital array will always contain the capitals.

The heap in the solution is storing the indices (not the actual values), and that's the solution logic.

We need to store indices because we want to reference both capital and profit arrays with it.

If we don't store...

On this page