389. Find the Difference

class Solution {

    /**
     * @param String $s
     * @param String $t
     * @return String
     */
    function findTheDifference($s, $t) {
        $targets = str_split($t);
        $strings = str_split($s);
        foreach($targets as $target) {
            $key = array_search($target, $strings);
            if ($key !== false) {
                unset($strings[$key]);
            } else {
                return $target;
            }
        }
    }
}

Last updated