일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 읽기
- 괜찮음
- 10분
- FIT XR
- Problem Solving
- 개발자
- Writing
- 프로젝트
- English
- 만화도
- leetcode
- 리얼 클래스
- 잡생각
- 뭐든
- 30분
- 쓰릴오브파이트
- 링피트
- 미드시청
- 스탭퍼
- 매일
- 월간
- 운동
- 파비최
- realclass
- 영어공부
- 3줄정리
- 화상영어
- 영어원서읽기
- 사이드
- Daily Challenge
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.03.06 Today's Challenge 본문
https://leetcode.com/problems/kth-missing-positive-number/
Kth Missing Positive Number - LeetCode
Can you solve this real interview question? Kth Missing Positive Number - Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Return the kth positive integer that is missing from this array. Example 1: Input:
leetcode.com
조금 허접하지만 내손으로 풀어봄.
이분탐색으로 찾는 방법도 있었다.
class Solution:
def findKthPositive(self, arr: List[int], k: int) -> int:
idx, res = 0, []
for i in range(1, 2001):
if i != arr[idx]:
res.append(i)
continue
if idx < len(arr) - 1:
idx += 1
return res[k-1]
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.03.08 Today's Challenge (0) | 2023.03.08 |
---|---|
2023.03.07 Today's Challenge (0) | 2023.03.07 |
2023.03.05 Today's Challenge (0) | 2023.03.05 |
2023.03.04 Today's Challenge (0) | 2023.03.04 |
2023.03.03 Today's Challenge (0) | 2023.03.03 |
Comments