๋ฌธ์
https://programmers.co.kr/learn/courses/30/lessons/12953
๋ด ๋ฌธ์ ํ์ด
def solution(arr):
if len(arr) == 1:
return arr[0]
else:
for i in range(len(arr) - 1):
if arr[i] < arr[i + 1]:
a = arr[i]
b = arr[i + 1]
else:
a = arr[i + 1]
b = arr[i]
for j in range(b, a * b + 1):
if j % a == 0 and j % b == 0:
arr[i + 1] = j
break
return arr[-1]
๐ ๊ตฌํ ๋ฌธ์ ๋ก, ์ฃผ์ด์ง ์ ๋ ฅ์ ์์์๋ถํฐ ๋ ์์์ ์ต์๊ณต๋ฐฐ์๋ฅผ ๊ตฌํด์ฃผ๋ ๊ฒ์ ๋ฐ๋ณตํ๋ค.
๐ก ํผ๋๋ฐฑ
- ์ต์ ๊ณต๋ฐฐ์๋ฅผ ๊ตฌํ๋ ๋ฐฉ๋ฒ๋ง ์๊ณ ์์ผ๋ฉด ์ฌ์ด ๋ฌธ์ ์๋ค.
'4๏ธโฃ Python > Problem Solving' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python Algorithm] ๊ณ๋จ ์ค๋ฅด๊ธฐ BOJ #2579 (0) | 2022.02.04 |
---|---|
[Python Algorithm] ๋ ๋ฐ๋จน๊ธฐ Programmers(Lv.2) (0) | 2022.02.04 |
[Python Algorithm] JadenCase ๋ฌธ์์ด ๋ง๋ค๊ธฐ Programmers(Lv.2) (0) | 2022.02.04 |
[Python Algorithm] ํ๋ ฌ์ ๊ณฑ์ Programmers(Lv.2) (0) | 2022.02.04 |
[Python Algorithm] ์ต๋๊ฐ๊ณผ ์ต์๊ฐ Programmers(Lv.2) (0) | 2022.02.04 |
๋๊ธ