Skip to content

Instantly share code, notes, and snippets.

@BalajiMalliswamy
Created April 26, 2022 16:05
Show Gist options
  • Save BalajiMalliswamy/0e5596d6d2149949de65ef963b977012 to your computer and use it in GitHub Desktop.
Save BalajiMalliswamy/0e5596d6d2149949de65ef963b977012 to your computer and use it in GitHub Desktop.
Given the string, check if it is a palindrome.
//Given the string, check if it is a palindrome.
//Example
// For inputString = "aabaa", the output should be
// solution(inputString) = true;
// For inputString = "abac", the output should be
// solution(inputString) = false;
// For inputString = "a", the output should be
// solution(inputString) = true.
func solution(inputString: String) -> Bool {
return inputString == String(inputString.reversed())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment