Functions for the problems related to LinkedList