LeetCode 83. Remove Duplicates from Sorted List(从有序链表中删除重复节点)
题意:从有序链表中删除重复节点。
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head == NULL || head -> next == NULL){
return head;
}
if(head -> val == head -> next -> val){
return deleteDuplicates(head -> next);
}
else{
head -> next = deleteDuplicates(head -> next);
return head;
}
}
};
LeetCode 83. Remove Duplicates from Sorted List(从有序链表中删除重复节点)的更多相关文章
- [LeetCode] 83. Remove Duplicates from Sorted List ☆(从有序链表中删除重复项)
描述 Given a sorted linked list, delete all duplicates such that each element appear only once. Exampl ...
- [LeetCode] 26. Remove Duplicates from Sorted Array ☆(从有序数组中删除重复项)
[LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项 描述 Given a sorted array nums, remove the d ...
- [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项 II
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项之二
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- [LeetCode] Remove Duplicates from Sorted Array II 有序数组中去除重复项之二
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For exampl ...
- 026 Remove Duplicates from Sorted Array 从排序数组中删除重复项
给定一个有序数组,你需要原地删除其中的重复内容,使每个元素只出现一次,并返回新的长度.不要另外定义一个数组,您必须通过用 O(1) 额外内存原地修改输入的数组来做到这一点.示例:给定数组: nums ...
- LeetCode 82,考察你的基本功,在有序链表中删除重复元素II
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode专题的第51篇文章,我们来看LeetCode第82题,删除有序链表中的重复元素II(Remove Duplicates ...
- [LeetCode] 83. Remove Duplicates from Sorted List 移除有序链表中的重复项
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
- [leetcode]83. Remove Duplicates from Sorted List有序链表去重
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
随机推荐
- P2P头部平台退出后,普通人如何避开投资理财的“雷区”?
编辑 | 于斌 出品 | 于见(mpyujian) 近期,P2P市场上不断传来不利消息,引起市场轩然大波,也打乱了投资者投资计划,是继续坚持自己的选择还是另择它路? 18日,陆金所作为千亿头部平台,宣 ...
- 2019 EIS高校安全运维赛 misc webshell
webshell 第一种思路: 1.菜刀都是http协议,发的包都是POST包,所以在显示过滤器下命令:http.request.method==POST 2.右键,追踪tcp流,发现是蚁剑流量 3. ...
- 开学考试学生成绩管理Java
首先student类 package xuexi; public class Student { private String stunumber; private String name; priv ...
- Java进阶学习(3)之对象容器(下)
对象数组 对象数组中的每个元素都是对象的管理者而非对象本身 对象数组的for—each循环 集合容器(HashSet) HashSet 数学中的集合,元素间满足互异性.确定性.无序性 HashSet& ...
- python换源
pip源的更新 引用自:PyPI使用国内源 # coding: utf-8 import platform import os os_type = platform.system() if " ...
- Mybatis空指针
查询数据,返回的字段要在 resultMap 中定义, <resultMap id="BaseResultMap" type="com...." > ...
- Jmeter之cookie处理的2中方法
不添加cookie会出现什么结果呢? 举例:1)登录 2)手机充值 2.登录HTTP请求 3.充值 4.查看结果树,登录是成功的,但是充值不成功,提示请先登录. 如何解决这个问题呢?添加Cookie管 ...
- html5异步单图片多图片上传两种实现方式 后台.net mvc接收
Asp.net mvc上传多张图片后台存储 前台页面通过<file name="img">标签数组上传图片,后台根据Request.Files["img&qu ...
- 计算机二级-C语言-程序修改题-190113记录-对指定字符串的大小写变换处理。
//给定程序中fun函数的功能是:将p所指的字符串中每个单词的最后一个字母改成大写.(这里的“单词”是指由空格隔开的字符串) //重难点:指针对数组的遍历.大小写转换的方法.第一种使用加减32 得到, ...
- CSS - px、em、%
px(像素).em.% 百分比 1. em 1.1 本元素给定字体的 font-size 值,如果元素的 font-size 为 14px ,那么 1em = 14px:如果 font-size 为 ...