- array_search: documentation ( source)
- in_array: documentation ( source)
- str_split: documentation ( source)
<?php
function colorSequences($i1,$i2)
{
$m = strlen($i1);
$n = strlen($i2);
$at = str_split($i2);
$count = 0;
for($i=0;$i<$m;$i++){
if(count($i2) > 0){
if( in_array($i1[$i],$at) ){
$key = array_search($i1[$i],$at);
unset($at[$key]);
}else{
$count++;
}
}else{
$count++;
}
}
return $count;
}
echo colorSequences("bc","abc");
?>