Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem number 1400 - Python #484

Open
NirBinyamin8 opened this issue May 3, 2024 · 2 comments
Open

problem number 1400 - Python #484

NirBinyamin8 opened this issue May 3, 2024 · 2 comments

Comments

@NirBinyamin8
Copy link

Greetings,

I did not find a solution to problem number 1400 in the Python language - that's why I added a solution to this problem, in addition I updated the readme file.

Copy link

welcome bot commented May 3, 2024

Thanks for helping us improve and opening your first issue here! Don't forget to give us a 🌟 to support us.

While you're waiting, I just wanted to make sure you've had a chance to look at our Readme and Pull Request Guidelines.

@crazyGru
Copy link

from collections import Counter

def can_construct_palindrome(s, k):
    # Count the frequency of each character in the string
    char_count = Counter(s)
    
    # Count the number of characters with odd frequency
    odd_count = sum(count % 2 for count in char_count.values())
    
    # If k is greater than or equal to the number of odd-count characters,
    # it's possible to construct k palindromic strings
    return k >= odd_count and k <= len(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants