Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int numRabbits(vector<int>& answers) {
- int len = answers.size(), res = 0;
- unordered_map<int, int> map;
- for (int& count : answers)++map[count];
- for (auto& p : map)
- {
- int minNum = p.first + 1;
- while (p.second > 0)
- {
- res += minNum;
- p.second -= minNum;
- }
- }
- return res;
- }
- };
Add Comment
Please, Sign In to add comment