Guest User

Untitled

a guest
Feb 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. class Solution {
  2. public:
  3. int numRabbits(vector<int>& answers) {
  4. int len = answers.size(), res = 0;
  5. unordered_map<int, int> map;
  6. for (int& count : answers)++map[count];
  7. for (auto& p : map)
  8. {
  9. int minNum = p.first + 1;
  10. while (p.second > 0)
  11. {
  12. res += minNum;
  13. p.second -= minNum;
  14. }
  15. }
  16. return res;
  17. }
  18. };
Add Comment
Please, Sign In to add comment