Python for beginners:
https://www.youtube.com/watch?v=egq7Z...
Code:
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
if(target in nums):
return nums.index(target);
else:
if(target<min(nums)):
return 0;
elif(target>max(nums)):
return len(nums);
else:
g=0;
m=0;
while(g<len(nums)):
if(nums[g]>target):
m=g;
break;
g=g+1;
return m;
0 Comments:
Post a Comment