You get votes, a Dictionary from names to how many votes each person has. You also get the name on a new vote.
Count the new vote and return votes.
The person called name gets one more vote. A name with no votes yet isn't in votes. It starts from 0, so after this vote it has 1. The order of the entries doesn't matter.
Example 1:
Input: votes = {"Ana": 3, "Ben": 5}, name = "Ana"
Output: {"Ana": 4, "Ben": 5}
Explanation: Ana had 3 votes. Now she has 3 + 1 = 4.
Example 2:
Input: votes = {"Ana": 3, "Ben": 5}, name = "Cara"
Output: {"Ana": 3, "Ben": 5, "Cara": 1}
Explanation: Cara had no votes yet. She starts from 0 and now has 1.
Example 3:
Input: votes = {}, name = "Max"
Output: {"Max": 1}
Explanation: This is the very first vote. Max now has 1.
Constraints:
votescan be empty.- Every count in
votesis at least 1. - Names are single words made of English letters.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
