ํจ์ solution์ ์ ์ x์ ์์ฐ์ n์ ์ ๋ ฅ ๋ฐ์, x๋ถํฐ ์์ํด x์ฉ ์ฆ๊ฐํ๋ ์ซ์๋ฅผ n๊ฐ ์ง๋๋ ๋ฆฌ์คํธ๋ฅผ ๋ฆฌํดํด์ผ ํฉ๋๋ค. ๋ค์ ์ ํ ์กฐ๊ฑด์ ๋ณด๊ณ , ์กฐ๊ฑด์ ๋ง์กฑํ๋ ํจ์, solution์ ์์ฑํด์ฃผ์ธ์.
- x๋ -10000000 ์ด์, 10000000 ์ดํ์ธ ์ ์์ ๋๋ค.
- n์ 1000 ์ดํ์ธ ์์ฐ์์ ๋๋ค.
| x | n | answer |
|---|---|---|
| 2 | 5 | [2,4,6,8,10] |
| 4 | 3 | [4,8,12] |
| -4 | 2 | [-4, -8] |
๋ฐ๋ณต๋ฌธ ๋ด ์ฐ์ฐ ์ํ
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
for(int i = 0; i < n; i++) {
answer[i] = (long)x * (i + 1);
}
return answer;
}
}๋ฐ๋ณต๋ฌธ ๋ด์์ ํด๋น ์ฐ์ฐ์ ์ํํ๋ค