Grokking Data Structures & Algorithms for Coding Interviews
Vote

0% completed

​

Solution: Maximum Count of Positive Integer and Negative Integer

.....

.....

.....

Like the course? Get enrolled and start learning!
A

Anonymous

· 2 years ago

I was thrown off by the possibility of multiple zeros. I had to stop and think about why I should have known that I would need 2 binary searches. The answer of course is that we are targeting (as the solution states) the 'boundary between negative and positive'. And since we can have multiple zeros, the boundary between negative and zero is not always the same (or the same -/+ 1) as the boundary between zero and positive. Thus, we need two binary searches to find both possible targets.

Show 1 reply

Reading Progress

0%


Vote for new content