-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
26-alstjr7437 #196
26-alstjr7437 #196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํธ๋ค๋ฅ ๋น ๋ฅด๊ฒ ํ์๋๋ฐ ๋ฑ์ผ๋ก ํธ์
จ๊ตฐ์?
์.. ์๋๋ค์ใ
ใ
class Solution {
fun solution(citations: IntArray): Int {
val sortedCitations = citations.sortedDescending()
var max = 0
for(i in sortedCitations.indices) {
if(sortedCitations[i]>= i+1){
max = i+1
}
}
return max
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฌ์ค ์ด ๋ฌธ์ ์ ์ต๋ ์ ์ ๋ฌธ์ ์ดํด๋ ๋ง์ด์ฃ ...
์ฌ๋ฐ๋ ๊ฒ, ์ด์งํ์์ผ๋ก๋ ํ ์ ์๋ต๋๋ค :)
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> citations) {
int begin = 0, end = 10000;
int answer = 0;
while(begin <= end) {
int mid = (begin + end) / 2;
int count = 0;
for(const auto& citation : citations) {
if(citation >= mid)
count++;
}
if(count >= mid) {
answer = mid;
begin = mid + 1;
} else {
end = mid - 1;
}
}
return answer;
}
๋ง์ต๋๋ค.... ๋ฌธ์ ์ดํด๋ฅผ ํ๋๊น ์ด๋ป๊ฒ ํด์ผํ ์ง ๋ฐ๋ก ๋์ค๋๋ผ๊ตฌ์!! ๊ทผ๋ฐ ๋ฌธ์ ์ดํด๊ฐ ์๋์ ์ธํฐ๋ท์ ์ฐธ๊ณ ํด๋ฒ๋ฆฐ;; ์ด์งํ์์ผ๋ก๋ ํ๋ฆฌ๋๊ตฐ์ def solution(citations):
citations.sort(reverse=True)
answer = max(map(min, enumerate(citations, start=1)))
return answer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ์์ ์ ํผ ์ฝ๋์ธ๋ฐ,
์ง์ง ๋ฐ๋ณด ๊ฐ์ด ํ์์๋ค์..
def solution(citations):
citations.sort(reverse=True)
count=0
for h in range(0,1001):
for j in citations:
if h<=j:
count+=1
if h<=count:
answer = h
count=0
return answer
์ ์์ ์ ์ง ์ฝ๋์ธ๋ฐ ์ง์ง ๋ฐ๋ณด๊ฐ์ด ํธ๋ ใ ๋ค์....
๋์ด๋ ์กฐ์ ์คํจ ใ ใ ์ ๋๋ค~ ์๋นค์น ๋ง์ผ์ธ์~
def solution(citations): | ||
citations.sort(reverse=True) | ||
|
||
for i in range(len(citations)): | ||
if(citations[i] < i+1): | ||
return i | ||
|
||
return len(citations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ์ฝ๋ 5์ค ๋ชจ์์
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3์ค๋ก ๋ง๋ ๋ณํ๋ค์ด ์๋๊ฑฐ ๋ณด๊ณ ์์ง ๋ถ์กฑํ๋ค๊ณ ๋๊ผ์ต๋๋ค....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ๋ ฌ์ reverseํ๋๊ฒ ํต์ฌ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ท
์ ์ฒ์์ ์ ๋ ฌ์ reverseํ๋ค๋ ๊ฑธ ์๊ฐ์ ๋ชปํด์ len(citations)/2๋ฅผ ๊ธฐ์ค์ผ๋ก h-index ๊ตฌ๋ถํ๊ณ .. ๋บ๋บ ๋๋ฌ๊ฐ๋ค์
์๊ณ ํ์ จ์ด๋ค-!
def solution(citations):
answer = 0
citations.sort(reverse = True)
for i in citations:
if answer < i:
answer += 1
else:
break
return answer
์ด ๋ง์ต๋๋ค!! reverse๋ฅผ ํ์ง ์๊ณ ํ ์๋ ์๋๋ฐ ์ํ๊ฒ ๋๋ฉด |
๐ ๋ฌธ์ ๋งํฌ
H-Index
โ๏ธ ์์๋ ์๊ฐ
20๋ถ
โจ ์๋ ์ฝ๋
์์ ์ ๊ฐ์ด
[3, 0, 6, 1, 5] ์ด ์๋ค๊ณ ๊ฐ์ ํ๋ฉด
์๋์ ๊ฐ์ด
[6, 5, 3, 1, 0]์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ์ ํ๊ฒ ๋ฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ ์๋์ ๊ฐ์ด ํ๋ฅผ ์ด์ฉํด์ ํ์ธํด๋ณด๋ฉด
์์ ๊ฐ์ด ์งํ์ ํ๊ฒ ๋์ด์
๊ฐ ์ธ์ฉ์๊ฐ ์ ์ผ ํฐ ์ต๋๊ฐ์ด ๋ ๋
1 < 4๋ ๋ ์์์ง๋ฏ๋ก X
์์ ์์ ์์๋ 3์ด ๋ฉ๋๋ค.
์ฌ์ค ์ฒ์์๋ ๋ฌธ์ ์ดํด๋ฅผ ์ ํํ ๋์ง ์์์ ์ธํฐ๋ท์ ์ฝ๊ฐ์ฉ ๊ฒ์์ ํด๋ณด๋ ์ ๋ ฌ์ ํ๊ณ ์ธ์ฉ์์ ์ต๋๋ฅผ ๋น๊ตํ๋ฉฐ ํ๋ ๋ถ๋ถ์ด๋๊ตฐ์.
๋ฌธ์ ๋ฅผ ์ดํดํ๋๊น ์ฝ๋๋ ๊ธ๋ฐฉ ์ฝ๊ฒ ๋์์ต๋๋ค..
์๊ฐ๋ณด๋ค ๋๋ฌด ์ฌ์์ ๋์ด๋ ์กฐ์ ์ ์คํจํด๋ฒ๋ฆฐ..๊ทธ๋ฆฌ๊ณ ์ฒ์์๋ len(citations)๋ฅผ ์ํ๊ฒ ๋์๋๋ฐ
4,4,4,4๊ฐ ๋ค์ด์ค๊ฒ ๋๋ฉด 4๊ฐ ๋์ผํ๋๋ฐ
i๋ฅผ ์ ์ฅํด๋๊ณ return i๋ฅผ ํ๊ฒ ๋๋๊น
0์ด ๋์ค๊ฒ ๋์์ต๋๋ค.
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
๋ฌธ์ ๋ฅผ ์ ์ดํดํ๋๊ฒ ์ ๋ง ์ค์ํ๋ค๊ณ ์๊ฐ๋ญ๋๋ค..