Using Bisect Module in python


  • 0
    D
    import bisect
    class Solution(object):
        def searchInsert(self, nums, target):
        	if target in nums:
        		return nums.index(target)
        	else:
        		bisect.insort(nums,target)
        		return nums.index(target)		
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.