Search in Rotated Sorted Array II ( LeetCode ) Problem Solution.
You are given a target value to to looking. If found within the array return
true
, otherwise return false
.
Example 1:
Input: nums = [2,5,6,0,0,1,2]
, target = 0
Output: true
Example 2:
Input: nums = [2,5,6,0,0,1,2]
, target = 3
Output: false
Solution :-
class Solution:
def search(self, nums: List[int], target: int) -> bool:
if(target in nums):
return True
else:
return False
Runtime: 48 ms, faster than 91.27% of Python3 online submissions for Search in Rotated Sorted Array II.
Memory Usage: 14.3 MB, but 5.72% of Python3 online submissions for Search in Rotated Sorted Array II.
0 Comments