class LinkedList { Node head; class Node { int data; Node next; Node(int d) { data = d; next = null; } } public void push(int new_data) { Node new_node = new Node(new_data); new_node.next = head; head = new_node; } //this function will delete the kth node in list void deleteNode(int position) { //if linked list is empty then return if (head == null) return; Node temp = head; if (position == 0) { head = temp.next; return; } for (int i=0; temp!=null && i=0;i--) { llist.push(p[i]); } //this will delete the kth node llist.deleteNode(k-1); //this will print the linked list after deleteion llist.printList(); } } } /* Given: 1->2->3->4->5->6 K=3 after deletion: 1->2->3->5->6 4 is the third last node from the end of linked list. */