def solution(c):
candi_h = []
if not max(c):
return 0
for h in range(1, max(c)+1):
l_h = 0
u_h = 0
for i in range(len(c)):
if c[i] >= h:
u_h += 1
if c[i] <= h:
l_h += 1
if (u_h >= h) and (l_h <= h):
candi_h.append(h)
return(max(candi_h))
โท ๋ฌธ์ ์ ๋ ผ๋ฆฌ๋ฅผ ๊ทธ๋๋ก ๊ตฌํํ์ฌ ํ์๋ค.
โถ ์๋์ ์ฝ๋๋ ๋ฌธ์ ์ ๋ ผ๋ฆฌ๋ฅผ ํ ์ค๋ก ๊น๋ํ๊ฒ ๊ตฌํํ์๋ค.
def solution(c):
c.sort(reverse = True)
h = max(map(min, enumerate(c, start = 1)))
return h
'Programming > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Level 2] ๊ตฌ๋ช ๋ณดํธ (0) | 2020.10.06 |
---|---|
[Level 2] ์ ํ๋ฒํธ ๋ชฉ๋ก (Python) (0) | 2020.10.05 |
[Level 2] ์์ฅ (Python) (0) | 2020.09.30 |
[Level 2] ๊ดํธ ๋ณํ (Python) (0) | 2020.09.30 |
[Level 2] ์ผ๊ฐ ๋ฌํฝ์ด (Python) (0) | 2020.09.29 |