We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functionalternatingCharacters($s){// Write your code here$stack=[];$deletions=0;for($i=0;$i<strlen($s);$i++){if(count($stack)===0){$stack[]=$s[$i];}else{$last=$stack[count($stack)-1];if($last===$s[$i]){$deletions++;}else{$stack[]=$s[$i];}}}return$deletions;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →
php