# leetcode 19 和leetcode 83

19. Remove Nth Node From End of List

struct ListNode* removeNthFromEnd(struct ListNode* head, int n) {
struct ListNode* ans;
for (int i = 0; i < n; ++i)
{
nex = nex -> next;
}

if (nex == NULL)
{
return ans;
}

while (nex -> next != NULL)
{
pre = pre -> next;
nex = nex -> next;
}
free(pre -> next);
pre -> next = pre -> next -> next;

}

leetcode 83问题描述：Given a sorted linked list, delete all duplicates such that each element appear only once.For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.

struct ListNode* deleteDuplicates(struct ListNode* head) {
{
while(p -> next)
{
if (p -> val != p -> next -> val)
{
p = p -> next;
}
else
{
struct ListNode* tmp = p -> next;
p -> next = p -> next -> next;
free(tmp);
}
}
}
}

public ListNode deleteDuplicates(ListNode head) {
}

• 本文已收录于以下专栏：

## LeetCode.83. Remove Duplicates from Sorted List（删除单链表中的重复元素）

Given a sorted linked list, delete all duplicates such that each element appear only once. For exam...

## LeetCode 83 - Remove Duplicates from Sorted List

Remove Duplicates from Sorted List题目链接 https://leetcode.com/problems/remove-duplicates-from-sorted...

## 怒刷leetcode题目（3）226,83,142,86

226 Invert Binary Tree 36.2% Easy Invert a binary tree. 4 / \ 2 ...

## leetcode 83 Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once. For examp...

## LeetCode笔记：83. Remove Duplicates from Sorted List

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)