diff --git a/lcci/05.06.Convert Integer/README.md b/lcci/05.06.Convert Integer/README.md index 9c14eb779b788..93ee5ccd0a072 100644 --- a/lcci/05.06.Convert Integer/README.md +++ b/lcci/05.06.Convert Integer/README.md @@ -91,6 +91,14 @@ impl Solution { } ``` +```swift +class Solution { + func convertInteger(_ A: Int, _ B: Int) -> Int { + return (Int32(A) ^ Int32(B)).nonzeroBitCount + } +} +``` + diff --git a/lcci/05.06.Convert Integer/README_EN.md b/lcci/05.06.Convert Integer/README_EN.md index b3f47402923d5..5a8c4995bba79 100644 --- a/lcci/05.06.Convert Integer/README_EN.md +++ b/lcci/05.06.Convert Integer/README_EN.md @@ -108,6 +108,14 @@ impl Solution { } ``` +```swift +class Solution { + func convertInteger(_ A: Int, _ B: Int) -> Int { + return (Int32(A) ^ Int32(B)).nonzeroBitCount + } +} +``` + diff --git a/lcci/05.06.Convert Integer/Solution.swift b/lcci/05.06.Convert Integer/Solution.swift new file mode 100644 index 0000000000000..07a53a2db366e --- /dev/null +++ b/lcci/05.06.Convert Integer/Solution.swift @@ -0,0 +1,5 @@ +class Solution { + func convertInteger(_ A: Int, _ B: Int) -> Int { + return (Int32(A) ^ Int32(B)).nonzeroBitCount + } +}

AltStyle によって変換されたページ (->オリジナル) /