CLEAR JAVA SOLUTION WITH DETAILED EXPLANATION!
ok lets do this!!\nso we are given a linked list and an number \'n\'\nthis n is the number of root from last which needs to be removed!!\nfor example\n1->2->3->
ok lets do this!!\nso we are given a linked list and an number \'n\'\nthis n is the number of root from last which needs to be removed!!\nfor example\n1->2->3->4->5->6->7\nn=3\nmeans we have to delete the 3rd node from the last(5th node from the beginning).\nnow that the question is clear !\n\nlets move to the answer!\npiece of advice-whenever you see a linked list removal type question ,always make a dummy node at the beginning!\nanyways!\n\nLOGIC-\n1>we keep two pointer slow and fast(both move one at a time)both initially at start of list(at the dummy node)\n2>we move the fast to n+1 places away from the slow pointer\n3>we then traverse the list we check if fast is equal to null or not,if it is null we know that the slow pointer has reached just one node  before the node we need to delete!\n4>then we slow.next=slow.next.next!\n\nshould we do a dry run!\nwhy not!\nsuppose:\n1->2->3->4->5->6\nn=2\nmake a dummy node with val=0;(we call this start)\nso now our list looks like\n0->1->2->3->4->5->6\nslow ,start , fast all are pointing to 0 valued node!\nafter executing step 2 of our algorithm we have \nslow and start still at 0\nbut fast is at node with val 3;\nnow we execute step 3\ndifferent positions of slow and fast is shown below!\n[slow=1,fast=4]->[slow=2,fast=5]->[slow=3,fast=6]->[slow=4,fast=null]\nwow!!slow have reached  one node before out target node\nnow just do slow.next=slow.next.next;\n\ndo a couple of dry runs on your own to get the logic!\n```\npublic ListNode removeNthFromEnd(ListNode head, int n) {\n    \n    ListNode start = new ListNode(0);\n    ListNode slow = start, fast = start;\n    start.next = head;\n    \n    \n    for(int i=1; i<=n+1; i++)   {\n        fast = fast.next;\n    }\n    \n    while(fast != null) {\n        slow = slow.next;\n        fast = fast.next;\n    }\n\n    slow.next = slow.next.next;\n    return start.next;\n}\n```\n\nhope it helps!\nupvote the answer if you like it so that more people can benefit !\n
['Java']