diff --git "a/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md" "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md" index 27f4631c9505d..883d15a935e95 100644 --- "a/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md" +++ "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md" @@ -137,6 +137,25 @@ function getMinimumTime(time: number[], fruits: number[][], limit: number): numb } ``` +#### Swift + +```swift +class Solution { + func getMinimumTime(_ time: [Int], _ fruits: [[Int]], _ limit: Int) -> Int { + var ans = 0 + + for fruit in fruits { + let index = fruit[0] + let num = fruit[1] + + ans += ((num + limit - 1) / limit) * time[index] + } + + return ans + } +} +``` + diff --git "a/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/Solution.swift" "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/Solution.swift" new file mode 100644 index 0000000000000..21781989e242d --- /dev/null +++ "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/Solution.swift" @@ -0,0 +1,14 @@ +class Solution { + func getMinimumTime(_ time: [Int], _ fruits: [[Int]], _ limit: Int) -> Int { + var ans = 0 + + for fruit in fruits { + let index = fruit[0] + let num = fruit[1] + + ans += ((num + limit - 1) / limit) * time[index] + } + + return ans + } +} \ No newline at end of file