My question is from a popular coding test.
Given a chain defined as follows:
class ListNode: def __init__(self, x): self.val = x