Java Solution using Two Pointer and in One Pass
Idea:- For solving this question in one pass we can use two pointer approach. In this approach we make two pointer and maintain a gap of size n-1 between these 
Idea:- For solving this question in one pass we can use two pointer approach. In this approach we make two pointer and maintain a gap of size n-1 between these two pointers. \nWhen first pointer is at the end of the list we sure that second pointer at n+1 position from end . Now we need only remove nth element with the help of second pointer.\nThe Only edge case is when (n==size of list).\n```\nclass Solution {\n    public ListNode removeNthFromEnd(ListNode head, int n) {\n        ListNode p1=head,p2=head;\n        while(p1!=null&&p1.next!=null){\n            if(n<=0){\n                p2=p2.next;\n            }\n            p1=p1.next;\n            --n;\n        }\n        if(n>0){                      // The only edge case removed with this condition\n            head=head.next;\n        }else{\n            p2.next=p2.next.next;\n        }\n        return head;\n    }\n}\n// If you like the code and concept than Please UpVote me :)
['Two Pointers', 'Java']