figure lef and right pointers marching in towards one another algorithm ispalindrome(value prevalue postvalue is determined to be palindrome or not word value strip(touppercase( lef right word length - while word[lef tword[rightand lef right lef lef right right end while return word[lef tword[right end ispalindrome in the ispalindrome algorithm we call method by the name of strip this algorithm discards punctuation in the stringincluding white space as result word contains heavily compacted representation of the original stringeach character of which is in its uppercase representation palindromes discard white spacepunctuationand case making these changes allows us to design simple algorithm while making our algorithm fairly robust with respect to the palindromes it will detect counting the number of words in string counting the number of words in string can seem pretty trivial at firsthowever there are few cases that we need to be aware of tracking when we are in string updating the word count at the correct place skipping white space that delimits the words as an example consider the string "ben ate hayclearly this string contains three wordseach of which distinguished via white space all of the previously listed points can be managed by using three variables index wordcount inw ord