def solution(a, x, d)
k = a.size
position = 0
if position+d >= x
return 0;
end
(0..k).each do |i|
if (a[i] - position) <= d
position = a[i]
if position+d >= x
return i;
end
end
-1
end
end
Created
February 11, 2016 08:42
-
-
Save ahmadhasankhan/e30307ef747aee28f5e1 to your computer and use it in GitHub Desktop.
Frog Interview Problem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment