83. 删除排序链表中的重复元素 leetcode
作者:
出来遛狗了 | 来源:发表于
2018-11-02 11:09 被阅读1次
image.png
/**
* Definition for singly-linked list.
* public class ListNode {
* public var val: Int
* public var next: ListNode?
* public init(_ val: Int) {
* self.val = val
* self.next = nil
* }
* }
*/
class Solution {
func deleteDuplicates(_ head: ListNode?) -> ListNode? {
if head.self == nil{
return head
}else{
var listN = head
while listN?.next != nil{
if listN?.val == listN?.next?.val{
listN?.next = listN?.next?.next
}else{
listN = listN?.next
}
}
}
return head
}
}
本文标题:83. 删除排序链表中的重复元素 leetcode
本文链接:https://www.haomeiwen.com/subject/ckvqxqtx.html
网友评论