반응형
옷가게 할인 받기
class Solution {
public static int solution(int price) {
int answer = 0;
if(price >= 100000 && price < 300000){
answer = (int) (price - (price * 0.05));
}
else if(price >= 300000 && price < 500000){
answer = (int) (price - (price * 0.1));
}
else if(price >= 500000){
answer = (int) (price - (price * 0.2));
System.out.println(answer);
}else {
answer = price;
}
return answer;
}
}
아이스 아메리카노
class Solution {
public int[] solution(int money) {
int[] answer = new int[2];
answer[0] = money / 5500;
answer[1] = money % 5500;
return answer;
}
}
나이 출력
class Solution {
public int solution(int age) {
return 2022 - age + 1;
}
}
배열 뒤집기
class Solution {
public int[] solution(int[] num_list) {
int[] answer = new int[num_list.length];
for(int i = num_list.length -1; i >=0; i--){
answer[i] = num_list[num_list.length - i - 1];
}
return answer;
}
}
728x90
반응형
'CodingTest' 카테고리의 다른 글
코딩테스트 입문 - Day 7 (0) | 2025.04.12 |
---|---|
코딩테스트 입문 - Day 6 (0) | 2025.04.12 |
프로그래머스 - 코딩테스트 입문 Day 4 (0) | 2025.04.12 |
리트 코드 - 1768. Merge Strings Alternately (0) | 2025.04.05 |
프로그래머스 - 코딩테스트 입문 Day 3 (0) | 2025.04.05 |