Google · Question 21 · Backtracking
Palindrome Permutation
Problem
Check if any permutation of the string can form a palindrome.
Approach
A palindrome can have at most one odd-count character.
Time O(n)Space O(1)
How it works
- 1Count frequencies of all characters.
- 2Count how many characters have odd counts.
- 3Return True if at most one, else False.
Sample input / output
Input: code Output: False
Constraints
1 <= s.length <= 5000; s consists of lowercase English letters.
Solution — read it, then walk it
Time O(n)Space O(1)Branches 1Returns 1source · Python
Scroll sideways for wide charts — the view follows the active step.
- start / end
- statement
- condition
- loop
- returns
- definition
1/14
StartSTART
Interactive control-flow diagram and step-by-step code walkthrough.
Recommended resourcesAffiliate links · may earn us a commission
Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits