Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Check Palindrome Rearrangement

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Check Palindrome Rearrangement. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

GoodLeap Home Improvement Financing application flows may process user-entered text that must satisfy simple structural rules. Given a string, determine whether its characters can be rearranged to form a palindrome.

A palindrome reads identically from left to right and right to left. The input is case-sensitive, and every character must be used exactly once. Return True if at least one valid rearrangement exists, otherwise return False.

Formal Specification

Implement can_form_palindrome(s), where s is a string containing lowercase English letters. Return a Boolean value.

A string can form a palindrome when no more than one character appears an odd number of times. For even-length strings, every character count must be even. For odd-length strings, exactly one character may have an odd count.

Constraints

  • 0 <= len(s) <= 100000
  • s contains only lowercase English letters
  • Every character must be used exactly once

Function Signature

def can_form_palindrome(s):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output