So I'm visiting each node and storing the val recursively. Once I reach the end, I set the val to the first val, go back set it to second val etc. Is this a vaild solution, or do I need to actually change the node.next values?
vals = []
def aux(node):
if not node:
return
else:
vals.append(node.val)
aux(node.next)
node.val = vals[0]
vals.pop(0)
aux(head)
return head