1. ๋ฌธ์ :https://school.programmers.co.kr/learn/courses/30/lessons/131701
2. ํ์ด
3์ค ๋ฐ๋ณต๋ฌธ์ผ๋ก ํด๊ฒฐํ๋ค.
์๊ฐ๋ณต์ก๋๊ฐ ๊ทธ๋ฆฌ ์ข์ง ์์๋ฏ
3. ์ฝ๋
import java.util.*;
class Solution {
public int solution(int[] elements) {
int answer = 0;
Set<Integer> hash = new HashSet();
int len = elements.length;
for(int id=1; id<len+1; id++){
for(int i=0; i<len; i++){
int temp = 0;
for(int k=0; k<id; k++){
if(i+k<len) temp += elements[i+k];
else temp += elements[i+k-len];
}
hash.add(temp);
}
}
return hash.size();
}
}
'๐ป Coding Problems Solving > Array | String | Loop' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BOJ 24337] ๊ฐํฌ์ ํ (0) | 2023.06.14 |
---|---|
[BOJ 2141] ์ฐ์ฒด๊ตญ (0) | 2023.06.08 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ๊ทค ๊ณ ๋ฅด๊ธฐ (์๋ฐ java) (0) | 2023.02.22 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์์ด ๋๋ง์๊ธฐ (์๋ฐ java) (0) | 2022.12.01 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์ซ์์ ํํ (์๋ฐ java) (0) | 2022.11.26 |
์ต๊ทผ๋๊ธ