카테고리 없음
[Java] 프로그래머스 - 카펫
C0MPAS
2024. 1. 25. 14:07
1월 25일(목) - 6장 완전 탐색
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
public class Solution {
public int[] solution(int brown, int yellow){
for(int width=3; width<=5000; width++)
{
for(int height=3; height<=width; height++)
{
int boundary = (width+height-2)*2;
int center = width*height - boundary;
if(brown == boundary && yellow == center)
{
return new int[] {width, height};
}
}
}
return null;
}
}