[LeetCode]题解(python):081-Search in Rotated Sorted Array II

题目来源:

  https://leetcode.com/problems/search-in-rotated-sorted-array-ii/


题意分析:

  根据题目"Search in Rotated Sorted Array",如果数字存在重复数字怎么处理。写一个函数,判断target是否在nums中。


题目思路:

  这里不能用二分查找,直接搜索一个判断就可以了。


代码(Python):

  

class Solution(object):
    def search(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: bool
        """
        for i in nums:
            if i == target:
                return True
        return False
View Code

转载请注明出处:http://www.cnblogs.com/chruny/p/5088584.html 

原文地址:https://www.cnblogs.com/chruny/p/5088584.html