class Solution {
/**
* @param String $s
* @return Integer
*/
function firstUniqChar($s) {
$words = str_split($s);
$table = [];
foreach($words as $word) {
$table[$word] ??= 0;
$table[$word]++;
}
$targets = array_filter($table, fn($item) => $item === 1);
if (count($targets) === 0){
return -1;
}
$keys = array_keys($targets);
return array_search($keys[0], $words);
}
}