leetcode1019】的更多相关文章

We are given a linked list with head as the first node.  Let's number the nodes in the list: node_1, node_2, node_3, ... etc. Each node may have a next larger value: for node_i, next_larger(node_i) is the node_j.val such that j > i, node_j.val > nod…
class Solution(object): def nextLargerNodes(self, head: ListNode) -> 'List[int]': n = 0 temp = head while temp != None: n += 1 temp = temp.next R = [0] * n Stack = list() index = 0 while head != None: #print(head.val) cur = head.val if len(Stack) ==…
""" We are given a linked list with head as the first node. Let's number the nodes in the list: node_1, node_2, node_3, ... etc. Each node may have a next larger value: for node_i, next_larger(node_i) is the node_j.val such that j > i, n…