<garvit244>1019_1.py
def nextLargerNodes( head):
    result = []
    while head:
        result.append(head.val)
        head = head.next
    
    stack = [result[-1]]
    ans = [0]
    for val in range(len(result)-2, -1, -1):
        if result[val] < stack[-1]:
            ans.append(stack[-1])
        else:
            while stack and stack[-1] <= result[val]:
                stack.pop()
            if stack:
                ans.append(stack[-1])
            else:
                ans.append(0)
        stack.append(result[val])
    return ans[::-1]
def sample_funcname ( var_0 ) :
    var_1 = [ ]
    while var_0 :
        var_1.append ( var_0.val )
        var_0 = var_0.next
    var_6 = [ var_1 [ - 1 ] ]
    var_8 = [ 0 ]
    for val in range ( len ( var_1 ) - 2 , - 1 , - 1 ) :
        if var_1 [ val ] < var_6 [ - 1 ] :
            var_8.append ( var_6 [ - 1 ] )
        else :
            while var_6 and var_6 [ - 1 ] <= var_1 [ val ] :
                var_6.pop ( )
            if var_6 :
                var_8.append ( var_6 [ - 1 ] )
            else :
                var_8.append ( 0 )
        var_6.append ( var_1 [ val ] )
    return var_8 [ : : - 1 ]
