<?php // continuing with complex anagrams // if we have "babc" and we want a signature for this to get // --> [1, 2, 1, 0, 0, 0, ... , 0] function buildingSignature($input) { $signature = array_fill(0, 26, 0); $input = strtolower($input); for ($i = 0; $i < strlen($input); $i++) { $char = $input[$i]; $signature[ord($char) - ord('a')] += 1; } return $signature; } var_dump(buildingSingature("babc"));die;
You have javascript disabled. You will not be able to edit any code.