We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 06a56f1 commit 17f67afCopy full SHA for 17f67af
Week9/공통/삼각달팽이/jiyoon_re.java
@@ -0,0 +1,38 @@
1
+package Week9.공통.삼각달팽이;
2
+
3
+public class jiyoon_re {
4
+ class Solution {
5
+ public int[] solution(int n) {
6
+ int[][] arr = new int[n + 1][n + 1];
7
8
+ int num = 1;
9
+ int x = -1, y = 0;
10
+ for (int i = 0; i < n; i++) {
11
+ for (int j = i; j < n; j++) {
12
+ if (i % 3 == 0) {
13
+ x++;
14
+ } else if (i % 3 == 1) {
15
+ y++;
16
+ } else if (i % 3 == 2) {
17
+ x--;
18
+ y--;
19
+ }
20
21
+ arr[x][y] = num;
22
+ num++;
23
24
25
26
+ int temp = 0;
27
+ int[] answer = new int[num - 1];
28
29
+ for (int j = 0; j <= i; j++) {
30
+ answer[temp] = arr[i][j];
31
+ temp++;
32
33
34
35
+ return answer;
36
37
38
+}
0 commit comments