Ctrl K

Even Out the Letters on Cards

Easy
Each card holds a word, given as the string array cards. In one move you may take any letter off one card and write it anywhere on another card. Return True if, after any number of moves, every card can show exactly the same word, and False otherwise.
Example 1
cards=["aab", "b", "ab"] → True

There are 3 a's and 3 b's across 3 cards: move the extra a to the second card and every card reads ab.

Example 2
cards=["xy", "x"] → False

There is a single y and two cards, so it cannot be split evenly.

Constraints
  • 1 ≤ len(cards) ≤ 100
  • 1 ≤ len(cards[i]) ≤ 100
  • cards[i] consists of lowercase English letters
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
cards=["aab", "b", "ab"]
Expected
True

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