Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions tasks/medium/strings/palindrome_anagram.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,23 @@ tags = ["strings"]
time_to_solve_sec = 300

description_en = """
Check if any anagram of a given string is a palindrome.

An anagram is a word formed by rearranging the letters of another word. A palindrome is a word that reads the same forwards and backwards.

For a string to have a palindromic anagram, at most one character can have an odd count.
Find out if it is possible to rearrange the letters of the string given so that it reads the same from left to right and from right to left.
"""

description_ru = """
Проверьте, является ли какая-либо анаграмма данной строки палиндромом.

Анаграмма слова - это слово, которое может быть получено путем перестановки его букв. Палиндром - это слово, которое одинаково читается в обоих направлениях.

Чтобы строка могла иметь анаграмму-палиндром, не более одного символа может встречаться нечетное количество раз.
Выясните, можно ли переставить буквы данной строки таким образом, чтобы она читалась одинаково слева направо и справа налево.
"""

limits = """
- $0 \\leq |\\text{s}| \\leq 100$
"""

solution = """
def solution(s: str) -> bool:
from collections import Counter
from collections import Counter

def solution(s: str) -> bool:
char_counts = Counter(s)
odd_count = sum(1 for count in char_counts.values() if count % 2 == 1)

odd_count = sum(count % 2 == 1 for count in char_counts.values())
return odd_count <= 1
"""

Expand Down
Loading