leetcode83~Remove Duplicates from Sorted List
来源:互联网 发布:sql 比较运算符 编辑:程序博客网 时间:2024/06/08 10:22
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.
public class RemoveDuplicatesfromSortedList { //迭代实现 public ListNode deleteDuplicates(ListNode head) { if(head==null) return null; ListNode node = head; while(node.next!=null) { if(node.val==node.next.val) { node.next = node.next.next; } else { node = node.next; } } return head; } //递归实现 public ListNode deleteDuplicates2(ListNode head) { if(head==null || head.next==null) return head; head.next = deleteDuplicates2(head.next); if(head.val==head.next.val) { return head.next; } else { return head; } }}
0 0
- LeetCode83:Remove Duplicates from Sorted List
- leetcode83 Remove Duplicates from Sorted List
- leetcode83:Remove Duplicates from Sorted List
- leetcode83: Remove Duplicates from Sorted List
- leetcode83. Remove Duplicates from Sorted List
- leetcode83~Remove Duplicates from Sorted List
- LeetCode83. Remove Duplicates from Sorted List
- LeetCode83. Remove Duplicates from Sorted List
- LeetCode83 Remove Duplicates from Sorted List
- LeetCode83——Remove Duplicates from Sorted List
- LeetCode83之Remove Duplicates from Sorted List的Java题解
- leetcode83---Remove Duplicates from Sorted List(删除重复元素)
- LeetCode83——Remove Duplicates from Sorted List
- leetcode83.Remove Duplicates from Sorted Lists
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove duplicates from sorted list
- Java 变量-基本类型
- 半导体设备数据Handshake
- Collection接口常用方法
- 强化学习读书笔记
- OkHttp源码阅读之旅(一)
- leetcode83~Remove Duplicates from Sorted List
- tomcat什么鬼,apache tomcat 一种服务器了咦
- 强化学习读书笔记_0
- Java初始化
- GYM 101149 A.Balls in Urn(水~)
- Node JS 中遇到过的问题
- 割点(模板)
- Spark性能优化指南——基础篇
- 割点(模板)