From 8152790c719e69f365dfc1a0e026dc968353ed61 Mon Sep 17 00:00:00 2001 From: Lanre Adedara Date: Mon, 11 Nov 2024 08:47:02 +0100 Subject: [PATCH] feat: add swift implementation to lcp problem: No.08 --- .../README.md" | 41 +++++++++++++++++++ .../Solution.swift" | 36 ++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 "lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift" diff --git "a/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md" "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md" index 7f3a754caf57c..f29879959c9dc 100644 --- "a/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md" +++ "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md" @@ -140,6 +140,47 @@ class Solution { } ``` +#### Swift + +```swift +class Solution { + func getTriggerTime(_ increase: [[Int]], _ requirements: [[Int]]) -> [Int] { + let m = increase.count, n = requirements.count + var s = Array(repeating: [0, 0, 0], count: m + 1) + + for i in 0.. Bool { + for i in 0..<3 { + if a[i] < b[i] { + return false + } + } + return true + } +} +``` + diff --git "a/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift" "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift" new file mode 100644 index 0000000000000..1b2606567fd06 --- /dev/null +++ "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift" @@ -0,0 +1,36 @@ +class Solution { + func getTriggerTime(_ increase: [[Int]], _ requirements: [[Int]]) -> [Int] { + let m = increase.count, n = requirements.count + var s = Array(repeating: [0, 0, 0], count: m + 1) + + for i in 0.. Bool { + for i in 0..<3 { + if a[i] < b[i] { + return false + } + } + return true + } +} \ No newline at end of file