Ctrl K

One Letter to Even Counts

Easy
You are given a string word of lowercase English letters. You must delete exactly one letter from it; leaving the string untouched is not allowed. Can you pick that letter so that every letter still present in the string appears the same number of times? Letters that no longer occur are ignored. Return true if it can be done and false otherwise.
Example 1
word='xxyyz' → True

Removing an x gives "xyyz" with counts 1, 2 and 1, which does not work. Removing the z leaves "xxyy", where both letters appear twice.

Example 2
word='ppqq' → False

Whichever letter goes, one letter ends up appearing once and the other twice.

Example 3
word='kkkk' → True

After removing one k only a single kind of letter is left, so there is nothing for its count to differ from.

Constraints
  • 2 ≤ word.length ≤ 100
  • word consists of lowercase English letters only
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsNote From Clipped Letters EasyFirst One-Off Letter EasyWords Heard Only Once EasyWords From Letter Tiles EasyBalloon Signs From Letters Easy
loading Python…
Input
word='xxyyz'
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.