Problem statement
One count array answers three questions. First, is t a rearrangement of s? Second, which letter of s appears exactly once, and at which position does the first such letter stand? Third, can the letters of s be arranged into a palindrome?
Every string is lowercase, so the array has 26 slots and a letter's slot is its position in the alphabet.
Examples
Inputs = "listen", t = "silent"
Outputrearrangement yes, first unique "l" at 0, palindrome no
Both strings hold the same six letters, every count is odd, and six odd counts is more than a palindrome can carry.
Inputs = "civic", t = "icvic"
Outputrearrangement yes, first unique "v" at 4, palindrome yes
c and i are counted twice and v once, so exactly one letter is left without a partner.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing