solved SimplifyPath problem using linked list