long
30710
30710
Rank2
2
Badges145
145
Score
long received Commenter badge for Problem 672. Longest run of consecutive numbers on 26 Apr 2024 |
long submitted a Comment to Problem 672. Longest run of consecutive numbers function val=longrun(a)
% Given vector
% a = [1 2 2 2 1 3 2 1 4 5 1];
maxn = 1;
skip = 2;
i = 1;
sz = size(a);
if sz(1)==1
a = [a,max(a)+1];
elseif sz(2) == 1
a = [a;max(a)+1];
end
max1 = -(max(a)+1);
while i < length(a)
for j = skip:length(a)
if a(j) ~= a(i)
skip = j+1;
% maxn = max(maxn, j-i);
if (j-i>maxn)
max1 = a(i);
elseif (j-i==maxn)
if (i~=1)
max1 = [max1, a(i)];
else
max1 = a(i);
end
end
maxn = max(maxn, j-i);
i = j;
break;
end
end
end
val = max1;
if sz(2) == 1
val = val'
end
end
on 26 Apr 2024 |
long submitted Solution 13694131 to Problem 672. Longest run of consecutive numbers on 26 Apr 2024 |
long submitted Solution 13693206 to Problem 44949. Find the Best Hotels on 26 Apr 2024 |
long submitted Solution 13693146 to Problem 44958. Crop an Image on 26 Apr 2024 |
long submitted Solution 13693096 to Problem 44945. Calculate BMI on 26 Apr 2024 |
long submitted Solution 13692946 to Problem 44934. Plot Damped Sinusoid on 26 Apr 2024 |
long submitted Solution 13692781 to Problem 44948. Calculate a Damped Sinusoid on 26 Apr 2024 |
long submitted Solution 13692686 to Problem 44951. Verify Law of Large Numbers on 26 Apr 2024 |
long submitted Solution 13692511 to Problem 44947. Find the Oldest Person in a Room on 26 Apr 2024 |
long submitted Solution 13692476 to Problem 44944. Convert from Fahrenheit to Celsius on 26 Apr 2024 |
long submitted Solution 13692461 to Problem 44943. Calculate Amount of Cake Frosting on 26 Apr 2024 |
long submitted Solution 13692401 to Problem 1. Times 2 - START HERE on 26 Apr 2024 |
long received Solver badge for Solution 13692371 on 26 Apr 2024 |
long submitted Solution 13692371 to Problem 44946. Solve a System of Linear Equations on 26 Apr 2024 |