Skip to content

Commit e987e73

Browse files
authored
[20251117] PGM / LV2 / n^2 배열 자르기 / 이인희
1 parent 3dbab61 commit e987e73

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```java
2+
class Solution {
3+
public int[] solution(int n, long left, long right) {
4+
long size = right - left + 1;
5+
int[] answer = new int[(int)size];
6+
for(int i = 0; i < size; i++){
7+
long index = left + i;
8+
long row = index / n;
9+
long col = index % n;
10+
answer[i] = (int)(Math.max(row, col) + 1);
11+
12+
// System.out.println(index + " " + row + " " + col);
13+
}
14+
return answer;
15+
}
16+
}
17+
18+
```

0 commit comments

Comments
 (0)