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();
    }
}

 

  • ๋„ค์ด๋ฒ„ ๋ธ”๋Ÿฌ๊ทธ ๊ณต์œ ํ•˜๊ธฐ
  • ๋„ค์ด๋ฒ„ ๋ฐด๋“œ์— ๊ณต์œ ํ•˜๊ธฐ
  • ํŽ˜์ด์Šค๋ถ ๊ณต์œ ํ•˜๊ธฐ
  • ์นด์นด์˜ค์Šคํ† ๋ฆฌ ๊ณต์œ ํ•˜๊ธฐ