-
-
Save spreered/4b5dc0114040cfe10109b1fc8ebe72a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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