Skip to content

Commit dcd2851

Browse files
committed
move: Move file to correct directory
1 parent 4de8394 commit dcd2851

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
//
2-
// 217. Contains Duplicate.swift
3-
// https://leetcode.com/problems/contains-duplicate/description/
2+
// 121. Best Time to Buy and Sell Stock.swift
3+
// https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/
44
// Algorithm
55
//
66
// Created by 홍승현 on 2024/04/26.
77
//
88

99
import Foundation
1010

11-
final class LeetCode217 {
12-
func containsDuplicate(_ nums: [Int]) -> Bool {
13-
Set(nums).count != nums.count
11+
final class LeetCode121 {
12+
func maxProfit(_ prices: [Int]) -> Int {
13+
if prices.count == 1 { return 0 }
14+
var diff = 0
15+
var left = 0
16+
var right = 0
17+
18+
while right < prices.endIndex {
19+
if prices[left] > prices[right] {
20+
left = right
21+
} else {
22+
diff = max(diff, prices[right] - prices[left])
23+
}
24+
right += 1
25+
}
26+
return diff
1427
}
1528
}

contains-duplicate/WhiteHyun.swift

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
//
2-
// 121. Best Time to Buy and Sell Stock.swift
3-
// https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/
2+
// 217. Contains Duplicate.swift
3+
// https://leetcode.com/problems/contains-duplicate/description/
44
// Algorithm
55
//
66
// Created by 홍승현 on 2024/04/26.
77
//
88

99
import Foundation
1010

11-
final class LeetCode121 {
12-
func maxProfit(_ prices: [Int]) -> Int {
13-
if prices.count == 1 { return 0 }
14-
var diff = 0
15-
var left = 0
16-
var right = 0
17-
18-
while right < prices.endIndex {
19-
if prices[left] > prices[right] {
20-
left = right
21-
} else {
22-
diff = max(diff, prices[right] - prices[left])
23-
}
24-
right += 1
25-
}
26-
return diff
11+
final class LeetCode217 {
12+
func containsDuplicate(_ nums: [Int]) -> Bool {
13+
Set(nums).count != nums.count
2714
}
2815
}

0 commit comments

Comments
 (0)