Given the matrix a, return the index r of the row with the most nonzero elements. Assume there will always be exactly one row that matches this criterion.

Example:

 Input  a = [ 1 2 0 0 0
              0 0 5 0 0 
              2 7 0 0 0
              0 6 9 3 3 ]
 Output r is 4

Solution Stats

19366 Solutions

7462 Solvers

Last Solution submitted on Feb 03, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers7462

Suggested Problems

More from this Author96

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!