Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 자연어처리
- leetcode
- 편스토랑
- Git
- programmers
- AI 경진대회
- SW Expert Academy
- ubuntu
- Kaggle
- 금융문자분석경진대회
- 우분투
- ChatGPT
- 맥북
- 코로나19
- 백준
- 프로그래머스 파이썬
- hackerrank
- 더현대서울 맛집
- dacon
- Real or Not? NLP with Disaster Tweets
- PYTHON
- 편스토랑 우승상품
- 데이콘
- 캐치카페
- Baekjoon
- github
- gs25
- 프로그래머스
- 파이썬
- Docker
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 81. Search in Rotated Sorted Array II (Python) 본문
Programming/코딩 1일 1문제
[leetCode] 81. Search in Rotated Sorted Array II (Python)
솜씨좋은장씨 2020. 11. 10. 00:01728x90
반응형
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).
You are given a target value to search. If found in 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
Follow up:
- This is a follow up problem to Search in Rotated Sorted Array, where nums may contain duplicates.
- Would this affect the run-time complexity? How and why?
Solution
class Solution:
def search(self, nums: List[int], target: int) -> bool:
answer = True
check_set = set(nums) & set([target])
if check_set == set():
answer = False
return answer
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 859. Buddy Strings (Python) (0) | 2020.11.12 |
---|---|
[leetCode] 1394. Find Lucky Integer in an Array (Python) (0) | 2020.11.11 |
[leetCode] 867. Transpose Matrix (Python) (0) | 2020.11.09 |
[leetCode] 43. Multiply Strings (Python) (0) | 2020.11.08 |
[leetCode] 1299. Replace Elements with Greatest Element on Right Side (Python) (0) | 2020.11.07 |
Comments