Dashboard Temp Share Shortlinks Frames API

HTMLify

Day 128
Views: 3 | Author: djdj
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class Solution {

    /**
     * @param String $s
     * @return Integer
     */
    function firstUniqChar($s) {
        $arr = str_split($s);
        $count = array_count_values($arr);
        foreach($arr as $c => $key){
            if($count[$key] == 1){
                return $c;
                exit();
            }
        }
        return -1;
    }
}