Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #1019
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Dec 28, 2023
1 parent 5fcbbd8 commit e6d5ae7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions content/leetcode/2023/12.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ title: 2023.12
draft: false
---

# 2023.12.28

```python
#
# @lc app=leetcode.cn id=1019 lang=python3
#
# [1019] 链表中的下一个更大节点
#


# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def nextLargerNodes(self, head: Optional[ListNode]) -> List[int]:
stack = []
res = []
while head:
while stack and stack[-1][1] < head.val:
res[stack.pop()[0]] = head.val
stack.append((len(res), head.val))
res.append(0)
head = head.next
return res


# @lc code=end
```

# 2023.12.27

```python
Expand Down

0 comments on commit e6d5ae7

Please sign in to comment.