28.实现strStr()Python

偷懒写法,emmm看了看题名,想了一下,这应该是让我实现Python的index()吧

    def removeElement(self, nums, val):
        """
        :type nums: List[int]
        :type val: int
        :rtype: int
        """
	    try:
    		haystack.index(needle)
    	        return haystack.index(needle)
        except:

                return -1

猜你喜欢

转载自blog.csdn.net/Mryang2333/article/details/85239003