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 | 29 |
| 30 |
Tags
- 자연어처리
- programmers
- gs25
- 맥북
- SW Expert Academy
- 편스토랑
- 데이콘
- 프로그래머스 파이썬
- 파이썬
- PYTHON
- AI 경진대회
- 프로그래머스
- github
- 캐치카페
- hackerrank
- ChatGPT
- 더현대서울 맛집
- Baekjoon
- 백준
- 코로나19
- 편스토랑 우승상품
- 우분투
- dacon
- Kaggle
- Real or Not? NLP with Disaster Tweets
- leetcode
- ubuntu
- Docker
- 금융문자분석경진대회
- Git
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



SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'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