From 5a4eea1789e7a37efaee288207aa6a6b4b397746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rau=CC=81l=20Pera=20Pairo=CC=81?= Date: Mon, 14 Feb 2022 00:59:50 +0000 Subject: [PATCH 1/2] Fixed isAlphanumeric property --- String/ValidPalindrome.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/ValidPalindrome.swift b/String/ValidPalindrome.swift index e6c3c90a..07c64474 100644 --- a/String/ValidPalindrome.swift +++ b/String/ValidPalindrome.swift @@ -33,7 +33,7 @@ class ValidPalindrome { } extension Character { - var isValid: Bool { + var isAlphanumeric: Bool { return isLetter || isNumber } } \ No newline at end of file From 99954e6dcdeb7f42ec01fa4f6052d3414e763799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rau=CC=81l=20Pera=20Pairo=CC=81?= Date: Mon, 14 Feb 2022 01:52:52 +0000 Subject: [PATCH 2/2] Updated sintaxis to swift style --- String/ValidPalindrome.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/String/ValidPalindrome.swift b/String/ValidPalindrome.swift index 07c64474..6fa01d62 100644 --- a/String/ValidPalindrome.swift +++ b/String/ValidPalindrome.swift @@ -19,13 +19,13 @@ class ValidPalindrome { while !sChars[j].isAlphanumeric && i < j { j -= 1 } - - if sChars[i] != sChars[j] { + + guard sChars[i] == sChars[j] else { return false - } else { - i += 1 - j -= 1 } + + i += 1 + j -= 1 } return true @@ -34,6 +34,6 @@ class ValidPalindrome { extension Character { var isAlphanumeric: Bool { - return isLetter || isNumber + isLetter || isNumber } } \ No newline at end of file