티스토리 뷰
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
long temp = x;
int index = 0;
while (index != n) {
answer[index] = temp;
index++;
temp += x;
}
return answer;
}
}
- 성공
- for문보다 while 문 생각이 먼저나서 while문으로 풀었음
class Solution {
public long[] solution(long x, int n) {
long[] answer = new long[n];
for(int i = 0; i < n; i++){
answer[i] = x * (i + 1);
}
return answer;
}
}
- 다른 사람 풀이
- 제일 깔끔해보임
'PS > programmers' 카테고리의 다른 글
Level2) 프린터 (0) | 2020.10.09 |
---|---|
Level1) 두 개 뽑아서 더하기 (0) | 2020.10.08 |
Level1) 하샤드 수 (0) | 2020.09.12 |
Level1) 콜라츠 추측 (0) | 2020.09.12 |
Level1) 최대공약수와 최소공배수 (0) | 2020.09.12 |
링크
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 드림코딩
- JPA 연관관계 매핑
- 김영한 JPA
- 백준
- 이펙티브자바 아이템59
- dreamcoding
- 백기선 스터디
- ㅇㄷㅇㅈ
- js promise
- 킹수빈닷컴
- 프로그래머스 SQL
- BOJ
- 프로그래머스
- GCP
- 이펙티브자바 스터디
- http
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- 모던자바스크립트
- 이펙티브자바 아이템60
- Spring Security
- 김영한 http
- REST API
- js array
- HTTP 완벽 가이드
- JS 딥다이브
- js api
- java
- HTTP 완벽가이드
- 이펙티브자바
- 패스트캠퍼스 컴퓨터공학 완주반
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함