Problem 32. Most nonzero elements in row
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
Problem Comments
-
11 Comments
Show
8 older comments
Alexander
on 12 Feb 2019
easy :) but nice
Rahul Gulia
on 20 Jul 2020
Could you please check my solution.
How come the solution example 2, 3 and 4 have r= 3, 5 and 4. When it should have been r = 4, 3 and 1.
As these are the maximum number of zeros in any of the given row.
Can someone please give me a hint on how the solutions are provided so different?
Rubeena Aafreen
on 22 Oct 2020
What are these matrices in last 3 test cases? Can someone help
Solution Comments
Show commentsProblem Recent Solvers7351
Suggested Problems
-
6520 Solvers
-
Back to basics 23 - Triangular matrix
1030 Solvers
-
472 Solvers
-
find the surface area of a cube
536 Solvers
-
1902 Solvers
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!