-
2 Comments
Haoyu Dai
on 30 Apr 2020
function y = lengthOnes(x)
cnt=0;
a=[];
L=strlength(x);
for i=1:L
if x(i)=='1'
cnt=cnt+1;
else
cnt=0;
end
a(i)=cnt;
end
[y,index]=max(a);
end
Syed Shahed
on 3 May 2020
Excellent work man :)
Suggested Problems
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1928 Solvers
-
Back to basics 9 - Indexed References
450 Solvers
-
Try 1.5.4: Celsius to Fahrenheit
847 Solvers
-
753 Solvers
-
4880 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!