https://programmers.co.kr/learn/courses/30/lessons/42842
Code
1
2
3
4
5
6
7
8
9
10
11
12
def solution(brown, yellow):
answer = []
for c in range(1, yellow + 1):
d = yellow / c
if d != int(d) or c > d:
continue
d = int(d)
if (c+2)*(d+2)-yellow == brown:
return [d+2, c+2]
return answer
Complexity
$O(n)$
- $n$ = len(yellow)
PREVIOUSEtc