Closed yileitu closed 2 years ago
题目编号和完整的代码提供一下
768. Max Chunks To Make Sorted II
class Solution(object):
def maxChunksToSorted(self, arr: [int]) -> int:
"""
:type arr: List[int]
:rtype: int
"""
mono_stack: List[int] = []
for num in arr:
if mono_stack and num < mono_stack[-1]:
max_in_chunk = mono_stack.pop()
while mono_stack and num < mono_stack[-1]:
mono_stack.pop()
mono_stack.append(max_in_chunk)
else:
mono_stack.append(num)
return len(mono_stack)
需要在配置里,将CodeType改成Python3
感谢!
例如定义一个函数:
LeetCode Console报错:
去除typing后
可以成功提交。
但是网页版的LeetCode是支持Python typing的。将第一段代码手动复制到网页的编辑器中不会报SyntaxError。望添加对Python typing的支持。