diff --git a/algorithms/Strings/isPalindrome.m b/algorithms/Strings/isPalindrome.m index f1f6583..d3967fb 100644 --- a/algorithms/Strings/isPalindrome.m +++ b/algorithms/Strings/isPalindrome.m @@ -3,16 +3,14 @@ % Gets the length of the input word. inputLength = length(inputWord); - + % Number of pairs to compare. lastIndex = floor( inputLength / 2); - - % for every pair of letters in the word check if they match. + y=1; + % for every pair of letters in the word check if they match for i = 1 : lastIndex if inputWord(i) ~= inputWord(end + (1 - i)) y = 0; - else - y = 1; end end