Skip to content

Commit fe6a366

Browse files
authored
Merge pull request #1342 from AlgorithmWithGod/LiiNi-coder
[20251107] PGM / LV2 / 연속 부분 수열의 합 / 이인희
2 parents 72fc1f7 + ee9319c commit fe6a366

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public int solution(int[] elements) {
6+
int length = elements.length;
7+
int[] arr = new int[length * 2];
8+
for(int i = 0; i < length * 2; i++){
9+
arr[i] = elements[i % length];
10+
}
11+
Set<Integer> set = new HashSet<>();
12+
for(int size = 1; size <= length; size++){
13+
for(int start = 0; start < length; start++){
14+
int sum = 0;
15+
for(int i = start; i < start + size; i++){
16+
sum += arr[i];
17+
}
18+
set.add(sum);
19+
}
20+
}
21+
22+
return set.size();
23+
}
24+
}
25+
26+
```

0 commit comments

Comments
 (0)