Last active
November 28, 2019 01:00
-
-
Save savioserra/98f4847cd0c7d2beeea7ed7b14efcb3b to your computer and use it in GitHub Desktop.
Palindrome Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var shouldSucceed = "ARARA"; | |
var shouldFail = "ARAR"; | |
print(isPalindrome(shouldSucceed)); | |
print(isPalindrome(shouldFail)); | |
} | |
bool isPalindrome(String testString) { | |
var start = 0; | |
var end = testString.length - 1; | |
while (start <= end) { | |
if (testString[start] != testString[end]) { | |
return false; | |
} | |
end--; | |
start++; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment