| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- 미드시청
- 운동
- 영어공부
- 만화도
- 3줄정리
- leetcode
- English
- Writing
- 괜찮음
- 뭐든
- realclass
- 사이드
- 스탭퍼
- 파비최
- 개발자
- 링피트
- FIT XR
- Daily Challenge
- 쓰릴오브파이트
- 리얼 클래스
- 매일
- Problem Solving
- 10분
- 화상영어
- 잡생각
- 30분
- 영어원서읽기
- 읽기
- 월간
- 프로젝트
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/132-pattern
132 Pattern - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
이것도 뒤에서 부터 순회하면서 스텍 사용해서 풀면 됨
class Solution:
def find132pattern(self, nums: List[int]) -> bool:
if len(nums)<3:
return False
second_num = -math.inf
stck = []
for i in range(len(nums) - 1, -1, -1):
if nums[i] < second_num:
return True
while stck and stck[-1] < nums[i]:
second_num = stck.pop()
stck.append(nums[i])
return False반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2022.05.09 |
|---|---|
| Today's Challenge (0) | 2022.05.08 |
| Today's Challenge (0) | 2022.05.06 |
| Today's Challenge (0) | 2022.05.05 |
| Today's Challenge (0) | 2022.05.04 |
Comments