From 71865e5044c480113480bbf19e49a1db840eec0b Mon Sep 17 00:00:00 2001
From: Lanre Adedara <lanre.adedara@shara.co>
Date: Tue, 12 Nov 2024 07:45:48 +0100
Subject: [PATCH] feat: add swift implementation to lcp problem: No.17

---
 .../README.md"                                | 19 +++++++++++++++++++
 .../Solution.swift"                           | 14 ++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100644 "lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift"

diff --git "a/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md" "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md"
index ef691e227f58a..7c8136ef52536 100644
--- "a/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md"	
+++ "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md"	
@@ -118,6 +118,25 @@ func calculate(s string) int {
 }
 ```
 
+#### Swift
+
+```swift
+class Solution {
+    func calculate(_ s: String) -> Int {
+        var x = 1
+        var y = 0
+        for c in s {
+            if c == "A" {
+                x = x * 2 + y
+            } else if c == "B" {
+                y = y * 2 + x
+            }
+        }
+        return x + y
+    }
+}
+```
+
 <!-- tabs:end -->
 
 <!-- solution:end -->
diff --git "a/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift" "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift"
new file mode 100644
index 0000000000000..d8f69186b0f44
--- /dev/null
+++ "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift"	
@@ -0,0 +1,14 @@
+class Solution {
+    func calculate(_ s: String) -> Int {
+        var x = 1
+        var y = 0
+        for c in s {
+            if c == "A" {
+                x = x * 2 + y
+            } else if c == "B" {
+                y = y * 2 + x
+            }
+        }
+        return x + y
+    }
+}
\ No newline at end of file