tiles, made of letter magnets. Any two magnets may swap places, whether they sit in the same string or in different ones, and you may make as many swaps as you like. The length of each string stays the same.
Return the largest number of strings that can be palindromes (reading the same forwards and backwards) at the same time after the swaps.tiles=['xyx', 'yy', 'xz'] → 2
The pool holds x three times, y three times and z once: that is only two letter pairs (one of x, one of y). Each of the three strings needs one pair, so at most two of them can become palindromes, for example "xzx" and "yy".
tiles=['ba', 'ab', 'c'] → 3
Swap the a of the first string with the b of the second to get "bb" and "aa"; "c" is a palindrome already. All three strings are palindromes.
tiles=['pq', 'rs', 'tu'] → 0
len(tiles) ≤ 1000len(tiles[i]) ≤ 100tiles[i] consists of lowercase English letterstiles=['xyx', 'yy', 'xz']
2
Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.