赞
踩
题目:
题解:
- func removeNthFromEnd(head *ListNode, n int) *ListNode {
- dummy := &ListNode{0, head}
- first, second := head, dummy
- for i := 0; i < n; i++ {
- first = first.Next
- }
- for ; first != nil; first = first.Next {
- second = second.Next
- }
- second.Next = second.Next.Next
- return dummy.Next
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。