오늘은 커리어데이라서 코드카타 1개 제출한 것만 올리겠다.
최소직사각형
긴 변과 짧은 변으로 정리한 다음 풀면 되는 문제였는데, 단어 구조를 몰라서 ai의 도움을 받았다.
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<vector<int>> sizes) {
int maxLong = 0;
int maxShort = 0;
for (const auto& card : sizes) {
int w = card[0];
int h = card[1];
int longSide = max(w, h);
int shortSide = min(w, h);
maxLong = max(maxLong, longSide);
maxShort = max(maxShort, shortSide);
}
return maxLong * maxShort;
}'TIL' 카테고리의 다른 글
| 2/06일자 TIL (0) | 2026.02.06 |
|---|---|
| 2/05일자 TIL (0) | 2026.02.05 |
| 2/03일자 TIL (0) | 2026.02.03 |
| 2/02일자 TIL (0) | 2026.02.02 |
| 1/30일자 TIL (0) | 2026.01.30 |