Common Gem Elements
Each string describes a rock’s composition, and each character represents an element found in it. The function gem_stones receives a list of strings arr. An element is considered a gem if it appears in every rock at least once. Return the number of such common characters.
Примеры
Ввод
["abcdde", "baccd", "eeabg"]Вывод
2Ввод
["abc", "abc", "abc"]Вывод
3Ввод
["ab", "cd"]Вывод
0Нужно реализовать
def gem_stones(arr: list[str]) -> int:
Теги
stringssethashmap
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
["abcdde","baccd","eeabg"]Expected
22
Input
["abc","abc","abc"]Expected
33
Input
["ab","cd"]Expected
04
Input
["abcd"]Expected
45
Input
["basketball","baseball"]Expected
56
Input
["abc"]Expected
3Focus radio
Paused · SomaFM · Fluid