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 ...
随机推荐
- 部署DVWA时的一些问题和解决办法(一)
第一个有可能遇到的问题 0x4 配置PHP 配置PHP,GD支持 系统从2017更新到2018多个php版本共存问题解决,phpinfo 显示7.0 ,而php -v 显示7.2问题 apt-get ...
- 树莓派4B踩坑指南 - (11)免费搭建网站(宝塔,花生壳)
目录 宝塔 安装宝塔面板 登录及初始化设置 安装网站 花生壳 安装花生壳 设置花生壳 测试 问题(未解决但不影响使用) 网站统计 树莓派这么低的功耗,不用来当服务器总感觉有点浪费...完成效果:htt ...
- Analog power pin UPF defination
在一个analog macro端口上,有些pin是always on的,有些是shut down的,如何描述这些pin的power属性?这是一个常见问题,驴就此机会大致描述一下常见的做法.对于这个问题 ...
- 启动MySQL5.7时报错:initialize specified but the data directory has files in it. Aborting.
启动MySQL5.7时报错:initialize specified but the data directory has files in it. Aborting 解决方法: vim /etc/m ...
- 三大查找算法(Java实现)
三大查找算法 1.二分查找(Binary Search) public class BinarySearch { public static void main(String[] args) { in ...
- js加密(七)steam登录
1. url: https://store.steampowered.com/login/?redir=&redir_ssl=1 2. target: 登录 3. 分析 3.1 老样子,抓包, ...
- 我的18vps~
自从买了18vps的香港虚拟主机后,就面临一个问题,浏览器无法访问它的apache服务,后来发现,需要同时开启nginx服务: /usr/local/nginx/sbin/nginx -c /usr/ ...
- 最新版的 vscode 怎么配置 Python?
请进 -- > https://www.zhihu.com/question/322530705/answer/860418884
- 吴裕雄 python 神经网络——TensorFlow实现回归模型训练预测MNIST手写数据集
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_dat ...
- 怎么拆分一个Excel工作簿中的多个工作表?
打开需要编辑的Excel文档.如图所示,工作簿下方有很多工作表.现在需要将这些工作表单独拆分开成一个个工作簿. 右键任意一个工作表标签,在弹出的下拉列表中选择查看代码.即弹出代码窗口.如下图所示. ...