We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 10b904f + 2936c48 commit 3ebae0bCopy full SHA for 3ebae0b
0224LJH/202511/16 PGM 연속 부분 수열.md
@@ -0,0 +1,42 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+class Solution {
6
7
+ static HashSet<Integer> set = new HashSet<>();
8
9
10
+ public int solution(int[] elements) {
11
+ int len = elements.length;
12
13
+ for (int i = 1; i <= len; i++){
14
+ int curLen = i;
15
16
+ int curSum = 0;
17
+ for (int j = 0; j < curLen; j++){
18
+ curSum += elements[j];
19
+ }
20
21
+ int st = 0;
22
+ int end = curLen-1;
23
+ set.add(curSum);
24
25
+ for (int j = 1; j < len; j++){
26
+ curSum -= elements[st];
27
+ st++;
28
+ end++;
29
+ end %= len;
30
+ curSum += elements[end];
31
32
33
34
35
36
37
38
+ int answer = set.size();
39
+ return answer;
40
41
+}
42
+```
0 commit comments