Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit835ea6a

Browse files
add 0456-132-pattern.py
1 parentb5d31a9 commit835ea6a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎python/0456-132-pattern.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
classSolution:
2+
deffind132pattern(self,nums:List[int])->bool:
3+
stack= []# pair [num, curLeftMin], mono-decreasing stack
4+
curMin=nums[0]
5+
6+
forninnums:
7+
whilestackandn>=stack[-1][0]:
8+
stack.pop()
9+
ifstackandn<stack[-1][0]andn>stack[-1][1]:
10+
returnTrue
11+
12+
stack.append([n,curMin])
13+
curMin=min(n,curMin)
14+
15+
returnFalse

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp