MapleStory Finger Point

๐Ÿƒ‍โ™€๏ธprogrammers/Java

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - java 5๋ช…์”ฉ

HYEJU01 2024. 5. 2. 09:39

๐Ÿ’ก 5๋ช…์”ฉ ์ž˜๋ž์„ ๋•Œ ์ฒซ๋ฒˆ์งธ ์‚ฌ๋žŒ์„ ์ถœ๋ ฅํ•œ๋‹ค.

๋ฐ˜๋ณต๋ฌธ์„ ํ†ตํ•ด์„œ ์ฆ๊ฐ๊ฐ’์„ ์กฐ์ ˆํ•ด์ฃผ๋ฉด ์‰ฝ๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋‹ค.

 

๋ฐฐ์—ด size ์žก๊ธฐ ๋ฒˆ๊ฑฐ๋กœ์›Œ ๋™์  ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ–ˆ๋‹ค.

import java.util.ArrayList;

class Solution {
    public ArrayList <String> solution(String[] names) {
        ArrayList <String> answer = new ArrayList<>();
        
        for (int i = 0 ; i < names.length; i+=5){
            answer.add(names[i]);
        }
        
        return answer;
    }
}