https://school.programmers.co.kr/learn/courses/30/lessons/120806
class Solution {
public int solution(int num1, int num2) {
int answer = 0;
answer = (int)(((double)num1 / num2) * 1000);
return answer;
}
}
num1 / num2 계산에서만 소수점이 필요하기 때문에 double로 강제 형변환을 해줌
(int)(((double)num1 / num2) * 1000); 앞에 int가 붙는 이유
이것도 가능!
public class Solution {
public int solution(int num1, int num2) {
int result = (int) (num1 / (double) num2 * 1000);
return result;
}
}
public class Solution {
public int solution(int num1, int num2) {
int result = (int) ((double)num1 / num2 * 1000);
return result;
}
}
class Solution {
public int solution(int angle) {
if (angle < 90) {
return 1;
} else if (angle == 90) {
return 2;
} else if (angle < 180) {
return 3;
} else {
return 4;
}
}
}90 < angle < 180 이 return 3; 인데, 90 < 을 어떻게 넣어주지…?angle < 90 와 angle == 90 지정했기 때문에 자동으로 90 < angle < 180 가 설정됨class Solution {
public int solution(int angle) {
int answer = 0;
if(0 < angle && angle < 90) {
answer = 1;
} else if(angle == 90) {
answer = 2;
} else if(90 < angle && angle < 180) {
answer = 3;
} else {
answer = 4;
}
return answer;
}
}class Solution {
public int solution(int angle) {
return angle == 180 ? 4 : angle < 90 ? 1 : angle == 90 ? 2 : angle > 90 ? 3 : 0;
}
}DESC or ASC
→ 오름차순 or 내림차순
Sort.Direction direction = isAsc ? Sort.Direction.ASC : Sort.Direction.DESC;
Sort sort = Sort.by(direction, sorBy);
Pageable pageable = PageRequest.of(page, size, sort);
여러 개를 한번에 조건을 주기 위해서 In이 필요
findAllByUserAndNameIn(user, folderNames);
→ 폴더 레포지토리에 쿼리 메서드 만들기
return "index :: #fragment";model.addAttribute("folders", folderServicer.getFolders(userDetails.getUser()));product.getProductFolderList.iterfor (ProductFolder productFolder : product.getProductFolderList()) {
}class Solution {
public int[] solution(int[] emergency) {
int[] answer = new int[emergency.length];
for (int i = 0; i < emergency.length; i++) {
for (int j = 0; j < emergency.length; j++) {
if (emergency[i] <= emergency[j]) {
answer[i] ++;
}
}
}
return answer;
}
}
3 : 3 = 같음 +1
3 : 76 = 작음 +1
3 : 24 = 작음 +1
3 = 376 : 3 = 큼
76 : 76 = 같음 +1
76 : 24 = 큼
76 = 124 : 3 = 큼
24 : 24 = 같음 +1
24 : 76 = 작음 +1
24 = 2