Function to check if the characters in the given string forms a Palindrome in O ( 1 ) extra space
function isPalindrome ( $ str ) { $ firstChar = 0 ; $ lastChar = count ( $ str ) - 1 ; $ ch = true ; for ( $ i = 0 ; $ i < count ( $ str ) ; $ i ++ ) { $ firstChar = firstPos ( $ str , $ firstChar , $ lastChar ) ; $ lastChar = lastPos ( $ str , $ lastChar , $ firstChar ) ;