Skip to content

Commit cfcda34

Browse files
authored
Merge pull request #1696 from AlgorithmWithGod/0224LJH
[20251217] PGM / Lv2 / 카펫 / 이종환
2 parents 4daa163 + de1bb07 commit cfcda34

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

0224LJH/202512/17 PGM 카펫.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
class Solution {
6+
public int[] solution(int brown, int yellow) {
7+
int len = brown+4;
8+
int half = len/2;
9+
int ans1 = -1;
10+
int ans2 = -1;
11+
int[] answer = new int[2];
12+
13+
for (int width = half-3; width >= 3 ; width--){
14+
int height = half-width;
15+
int temp = 0;
16+
if ((width-2)*(height-2) == yellow){
17+
answer[0] = width;
18+
answer[1] = height;
19+
return answer;
20+
}
21+
}
22+
23+
24+
25+
return answer;
26+
}
27+
}
28+
```

0 commit comments

Comments
 (0)