From 97684b8d4002d17a18feec81132ca3064c775940 Mon Sep 17 00:00:00 2001 From: kNOzone <72206118+kNOzone@users.noreply.github.com> Date: Sun, 4 Oct 2020 12:26:41 +0530 Subject: [PATCH] Update isPalindrome.m --- algorithms/Strings/isPalindrome.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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