Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
maxOnexIdx variable initializing with Zero

luidymorais

Dec 18, 2023

Despite the solution explanation tells maxOnexIdx variable will initialize with -1, the code is showing is starting with zero. What is expected behaviour if there is no Ones in 2D-matrix?

2

0

Comments
Comments
Jay Karlsven
Jay Karlsven2 years ago

Agreed -- the problem never specified what to return if no rows contain any 1s. So I feel that initializing that variable to 0 is fine. There was no requirement around that condition.

On this page