// hash as sorted chars of word
// i.e. 'ababcad' -> 'aabbcd'
function word_hash($word) {
$chars = str_split($word);
sort($chars);
return implode($chars);
}
// return grouped by word_hash array of words
function get_words_grouped_by_chars($words) {
$hashes = [];
$group_of_words = [];
foreach($words as $key => $value) {
if (!is_string($value))
throw new \InvalidArgumentException('Массив может содержать только строки.');
$hash = word_hash($value);
if (!array_key_exists($hash, $hashes)) {
$hashes[$hash] = $value;
$group_of_words[$hashes[$hash]] = [];
}
array_push($group_of_words[$hashes[$hash]], $value);
}
uksort($group_of_words, function($a, $b) { return strlen($b) - strlen($a); });
return array_values($group_of_words);
}
sudo apt-get install python-dev python3-dev
делали?:echo has('python') || has('python3')
? class G_tost {
public static int getCount(String s, char ch) {
int res = 0;
for (int i = 0; i < s.length(); i++) {
res += s.charAt(i) == ch ? 1 : 0;
}
return res;
}
public static void main(String[] args) {
String data = "hhyhddrdffrfaasxf";
int ans = 0;
char ch = data.charAt(0);
for (int i = 0; i < data.length(); i++) {
int l = getCount(data, data.charAt(i));
if (ans < l) {
ch = data.charAt(i);
ans = l;
}
}
System.out.format("Char: %c, count: %d\n", ch, ans);
}
}