Skip to content

Instantly share code, notes, and snippets.

@spreered

spreered/search_insert.rb Secret

Created Sep 13, 2017
Embed
What would you like to do?
def search_insert(nums, target)
pre= nums[0]
pos = 0
if pre >= target
return 0
else
(1...nums.length).each do |i|
if(nums[i] >= target)
return i
end
pos = i
end
pos = nums.length
return pos
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment