From 50c344df7195caf247c1606d29ee1886bbc82225 Mon Sep 17 00:00:00 2001 From: Lanre Adedara Date: Tue, 19 Nov 2024 07:21:58 +0100 Subject: [PATCH 1/3] feat: add swift implementation to lcp problem: No.40 --- .../README.md" | 51 +++++++++++++++++++ .../Solution.swift" | 46 +++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 "lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" diff --git "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" index 4e21105c919d4..ccc59ff91acff 100644 --- "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" +++ "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" @@ -235,6 +235,57 @@ function maxmiumScore(cards: number[], cnt: number): number { } ``` +#### Swift + +```swift +class Solution { + func maxmiumScore(_ cards: [Int], _ cnt: Int) -> Int { + let sortedCards = cards.sorted() + let n = sortedCards.count + var ans = 0 + + for i in 0..= 0 ? maxScore : 0 + } +} +``` + diff --git "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" new file mode 100644 index 0000000000000..35c554fe589a7 --- /dev/null +++ "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" @@ -0,0 +1,46 @@ +class Solution { + func maxmiumScore(_ cards: [Int], _ cnt: Int) -> Int { + let sortedCards = cards.sorted() + let n = sortedCards.count + var ans = 0 + + for i in 0..= 0 ? maxScore : 0 + } +} \ No newline at end of file From 9ce9619e2b9aba49c021db00015c3c8b3f6d8bad Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Tue, 19 Nov 2024 18:58:51 +0800 Subject: [PATCH 2/3] Update README.md --- .../README.md" | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" index ccc59ff91acff..1b44a5d0836b8 100644 --- "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" +++ "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" @@ -239,24 +239,24 @@ function maxmiumScore(cards: number[], cnt: number): number { ```swift class Solution { - func maxmiumScore(_ cards: [Int], _ cnt: Int) -> Int { + func maximumScore(_ cards: [Int], _ cnt: Int) -> Int { let sortedCards = cards.sorted() let n = sortedCards.count var ans = 0 - + for i in 0..= 0 ? maxScore : 0 } } From eaeffc716e2b246e628c1aa9e71db39eb9d0abcc Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Tue, 19 Nov 2024 18:59:02 +0800 Subject: [PATCH 3/3] Update Solution.swift --- .../Solution.swift" | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" index 35c554fe589a7..767c90eeef9df 100644 --- "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" +++ "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" @@ -1,22 +1,22 @@ class Solution { - func maxmiumScore(_ cards: [Int], _ cnt: Int) -> Int { + func maximumScore(_ cards: [Int], _ cnt: Int) -> Int { let sortedCards = cards.sorted() let n = sortedCards.count var ans = 0 - + for i in 0..= 0 ? maxScore : 0 } -} \ No newline at end of file +}