Junior

Palindrome Permutation

Given a string s, determine if some permutation of s can form a palindrome.

A palindrome reads the same forward and backward. Return true if at least one rearrangement of the characters in s is a palindrome; otherwise, return false.

Example 1
Inputs = "code"
Outputfalse
The characters in code cannot be rearranged so that at most one character has an odd count.
Example 2
Inputs = "aab"
Outputtrue
The string can be rearranged as aba, which is a palindrome.

Constraints

  • 1 <= s.length <= 5000
  • s consists of lowercase English letters.

Asked at 8 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate