From a80938b4e9d0cb4f68acb2b1d3d87b3ccb7c6cb0 Mon Sep 17 00:00:00 2001 From: Lanre Adedara Date: Mon, 11 Nov 2024 08:56:54 +0100 Subject: [PATCH] feat: add swift implementation to lcp problem: No.11 --- .../README.md" | 11 +++++++++++ .../Solution.swift" | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 "lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift" diff --git "a/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md" "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md" index e9159c998fec7..62db68dcdb726 100644 --- "a/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md" +++ "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md" @@ -125,6 +125,17 @@ function expectNumber(scores: number[]): number { } ``` +#### Swift + +```swift +class Solution { + func expectNumber(_ scores: [Int]) -> Int { + let uniqueScores = Set(scores) + return uniqueScores.count + } +} +``` + diff --git "a/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift" "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift" new file mode 100644 index 0000000000000..af188317abaf1 --- /dev/null +++ "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift" @@ -0,0 +1,6 @@ +class Solution { + func expectNumber(_ scores: [Int]) -> Int { + let uniqueScores = Set(scores) + return uniqueScores.count + } +}