Created
September 21, 2019 09:02
-
-
Save surinoel/2b5975456599d28051279a04fa54d681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
using namespace std; | |
int cnt[10001]; | |
int solution(vector<int> citations) { | |
int answer = 0; | |
int size = citations.size(); | |
for (int i = 0; i < size; i++) { | |
cnt[citations[i]] += 1; | |
} | |
int sum = 0; | |
for (int i = 10000; i >= 0; i--) { | |
sum += cnt[i]; | |
if (sum >= i) { | |
answer = i; | |
break; | |
} | |
} | |
return answer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment