一、题目内容
二、题解
解法1:
思路
代码
public class Solution {public ListNode removeNthFromEnd(ListNode head, int n) {ListNode fast = head, slow = head;for (int i = 0; i < n; i++) {fast = fast.next;}if(fast == null){return head.next;}while (fast.next != null) {fast = fast.next;slow = slow.next;}slow.next = slow.next.next;return head;}}
