Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding solve for 1400 #483

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

Open
NirBinyamin8 wants to merge 1 commit into codedecks-in:master
base: master
Choose a base branch
Loading
from NirBinyamin8:Nir-Branch

Conversation

Copy link

@NirBinyamin8 NirBinyamin8 commented May 3, 2024

Given a string s and an integer k, return true if you can use all the characters in s to construct k palindrome strings or false otherwise.

The Readme.md file has been updated.

Copy link

welcome bot commented May 3, 2024

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

Copy link
Author

issue #484

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
Reviewers
1 more reviewer

@anandfresh anandfresh anandfresh approved these changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /