-
Notifications
You must be signed in to change notification settings - Fork 0
/
dayThree.swift
46 lines (38 loc) · 1.04 KB
/
dayThree.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// AppDelegate.swift
// DeleteRepeatsOfTheArray
//
// Created by KSummer on 2020/1/3.
// Copyright © 2020 KSummer. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
func mergeTwoLists(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {
if l1 == nil {
return l2
} else if l2 == nil {
return l1
}
let a = CGFloat.init(Float(l1?.val ?? 0))
let b = CGFloat.init(Float(l2?.val ?? 0))
if (a < b) {
l1?.next = mergeTwoLists(l1?.next, l2)
return l1
} else {
l2?.next = mergeTwoLists(l1, l2?.next)
return l2
}
}
}
class ListNode {
public var val: Int
public var next: ListNode?
public init(_ val: Int) {
self.val = val
next = nil
}
}