Shouldn’t the insertion in singly linked list be done via maintaining a tail pointer?
Otherwise, one always need to traverse the list till end and then add the new node, which means time complexity will be O(n) and not O(1).
Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers