일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 안정해시
- spring mongodb
- spring mongoTemplate
- rabbitmq 싱글톤
- go
- 전략 패턴이란
- java 1238
- java 백준 1509
- 익명 객체 @transactional
- javav 1676
- ipfs bean
- Spring ipfs
- java 1509
- kotiln const
- 자바 백준 팩토리얼 개수
- spring mongodb switch
- java 파티
- Java Call By Refernce
- 백준 연결요소 자바
- java 팩토리얼 개수
- nodejs rabbitmq
- kotiln const val
- 백준 특정한 최단 경로
- ipfs singletone
- 백준 2252 줄세우기
- mongodb lookup
- spring mongoTemplate switch
- kotiln functional interface
- 백준 1504 java
- 자바 1676
Archives
- Today
- Total
공부 흔적남기기
프로그래머스 최소직사각형 본문
728x90
반응형
class Solution {
public int solution(int[][] sizes) {
int answer = 0;
int[][] firstCheck = new int[sizes.length][2];
int sero =0;
int garo = 0;
//이문제는 실제로 상상하면서 풀어봐야함
//내가 실제로 명함 지갑을 위 조건을 맞춰 만든다고 생각하자
//그러면 명함지갑을 돌려서 각 명함의 긴쪽을 가로나 길이 둘중 하나로 설정하여 돌린다
//그러면 가로길이중에서 가장긴것과 세로길이중 가장 긴것을 가져오면 끝이다.
for(int i =0; i< sizes.length; i++){
//긴것을 가로로 짧은것을 세로로 바꿔줌
if (sizes[i][0] < sizes[i][1]) {
int temp = sizes[i][0];
sizes[i][0] = sizes[i][1];
sizes[i][1] = temp;
}
//가로길이중에 가장 긴것
if(sizes[i][0] >garo){
garo = sizes[i][0];
}
//세로길이중에 가장 긴것
if(sizes[i][1]> sero){
sero = sizes[i][1];
}
}
return garo*sero;
}
}
출처: https://programmers.co.kr/learn/courses/30/lessons/86491
코딩테스트 연습 - 최소직사각형
[[10, 7], [12, 3], [8, 15], [14, 7], [5, 15]] 120 [[14, 4], [19, 6], [6, 16], [18, 7], [7, 11]] 133
programmers.co.kr
728x90
반응형
'코테 > 프로그래머스' 카테고리의 다른 글
프로그래머스 두 개 뽑아서 더하기 (0) | 2022.01.15 |
---|---|
프로그래머스 같은 숫자는 싫어 (0) | 2022.01.15 |
프로그래머스 3진법 뒤집기 (0) | 2022.01.15 |
프로그래머스 햐사드 수 (0) | 2022.01.15 |
프로그래머스 콜라츠 추측 (0) | 2022.01.15 |