diff --git "a/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md" "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md" index 14bac274a24df..faf7cedef5e2f 100644 --- "a/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md" +++ "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md" @@ -183,6 +183,31 @@ impl Solution { } ``` +#### Swift + +```swift +class Solution { + func temperatureTrend(_ temperatureA: [Int], _ temperatureB: [Int]) -> Int { + var maxTrend = 0 + var currentTrend = 0 + + for i in 0.. 0) { + currentTrend += 1 + maxTrend = max(maxTrend, currentTrend) + } else { + currentTrend = 0 + } + } + + return maxTrend + } +} +``` + diff --git "a/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/Solution.swift" "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/Solution.swift" new file mode 100644 index 0000000000000..b0807755dc2a1 --- /dev/null +++ "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/Solution.swift" @@ -0,0 +1,20 @@ +class Solution { + func temperatureTrend(_ temperatureA: [Int], _ temperatureB: [Int]) -> Int { + var maxTrend = 0 + var currentTrend = 0 + + for i in 0.. 0) { + currentTrend += 1 + maxTrend = max(maxTrend, currentTrend) + } else { + currentTrend = 0 + } + } + + return maxTrend + } +} \ No newline at end of file