A word game shows a string of lowercase letters s. The player must remove exactly one character, and they win if every letter left in the string then appears the same number of times.
Write canEvenOut(s) that returns true if some single removal makes every remaining letter's count equal, and false otherwise. Letters that no longer appear don't count.
Input: s = "aabbccc" Output: true
Remove one c to get aabbcc: every letter appears twice.
Input: s = "aabbcc" Output: false
Any removal leaves one letter with 1 copy and two letters with 2.
2 <= s.length <= 10^5s has only lowercase letters.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #20 One Removal to Even Out Counts. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.