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

0% completed

Vote For New Content
Breaks where elements are larger than size of the array

rgithinji

May 28, 2024

The solution breaks if the value of an element (or elements) exceed the length of the array. An element is picked from the heap and used to search for a corresponding profit value by position and kaboooom! ArrayOutOfBounds exception.This makes it a special case solution that only works with the defined use cases. I'd rather a general solution with worse runtime complexity than a brittle special case solution

0

0

Comments
Comments

On this page