Convert a linked list to an array list.
Example
Given 1->2->3->null
, return [1,2,3]
class Solution:
"""
@param head: the head of linked list.
@return: An integer list
"""
def toArrayList(self, head):
r = []
while head is not None:
r.append(head.val)
head = head.next
return r