[Java] ํ๋ก๊ทธ๋๋จธ์ค - x๋งํผ ๊ฐ๊ฒฉ์ด ์๋ n๊ฐ์ ์ซ์
๐ก๋ฌธ์ ์ค๋ช
ํจ์ solution์ ์ ์ x์ ์์ฐ์ n์ ์
๋ ฅ ๋ฐ์, x๋ถํฐ ์์ํด x์ฉ ์ฆ๊ฐํ๋ ์ซ์๋ฅผ n๊ฐ ์ง๋๋ ๋ฆฌ์คํธ๋ฅผ ๋ฆฌํดํด์ผ ํฉ๋๋ค. ๋ค์ ์ ํ ์กฐ๊ฑด์ ๋ณด๊ณ , ์กฐ๊ฑด์ ๋ง์กฑํ๋ ํจ์, solution์ ์์ฑํด์ฃผ์ธ์. ์
์ถ๋ ฅ ์ x n answer 2 5 [2,4,6,8,10] 4 3 [4,8,12] -4 2 [-4, -8] package x๋งํผ๊ฐ๊ฒฉ์n๊ฐ์์ซ์; import java.util.Arrays; class Solution { public long[] solution(long x, int n) { long[] answer = new long[n]; for(int i=0; i
2022. 3. 20.