digits made of digits. Find the longest non-empty run of consecutive characters whose digits can be rearranged into a palindrome, a string that reads the same forwards and backwards.
Return the length of that run.digits="4747123" → 5
The run "47471" can be rearranged into the palindrome "47174": there are two 4s, two 7s and a single 1 that goes in the middle. Nothing longer works: "474712" already has two digits with an odd count.
digits="908" → 1
All the digits differ, so only a single-digit run works.
digits="1221" → 4
The whole string is already a palindrome.
digits contains only the digits 0–9digits="4747123"
5
Run checks the first 3 tests in your browser. Submit checks all 136 tests on the server, hidden ones included.