Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created September 21, 2019 09:02
Show Gist options
  • Save surinoel/2b5975456599d28051279a04fa54d681 to your computer and use it in GitHub Desktop.
Save surinoel/2b5975456599d28051279a04fa54d681 to your computer and use it in GitHub Desktop.
#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