Prasad, I enjoyed thinking through the pattern to solve this problem and the related problem. One suggestion for both is to add more test cases so that solvers cannot simply write their codes to return the answer to the single test case.
Needs more test cases.
1455 Solvers
409 Solvers
Flag largest magnitude swings as they occur
592 Solvers
Switch matrix to a column vector
267 Solvers
Matlab Basics II - Create a vector with a repeated entry
187 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!