๐ก ๋ ์ง ๋๊ฐ ์ค ์์๋ ๋ ์ง๋ฅผ ๊ณ ๋ฅด๋ ์ฝ๋์ด๋ค.
์ฆ data1 ์ด ๋ ๋๋ฆฐ ๋ ์ง๋ฉด 1์ ์ถ๋ ฅํ๋ค.
1) Y1 < Y2 -> ๋ฌด์กฐ๊ฑด ๋ ๋๋ฆผ// ๊ฒฐ๊ณผ๊ฐ 1
2) M1 < M2 -> ๋ ๋๋ฆผ
3) D1 < D2 -> ๋ ๋๋ฆผ
์ด๋ ๋ฐ๋ก๋ฅผ ์ฃผ์ํด์ผํ๋ค.
๋ท๊ฐ์ด ์์๊ฒฝ์ฐ ๊ทธ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ์ผ๋ก ์ถ๋ ฅํ๊ฒ ๋๋ค !!
------------------------
[10000, 12, 15] <=> [0, 12, 17]
1) Y1 > Y2 -> ๋ ํฌ๋ฏ๋ก ๋น ๋ฆ// ํจ์ค
2) M1 == M2 -> ๊ฐ์ // ํจ์ค
3) D1 < D2 -> ์์ // ๊ฒฐ๊ณผ๊ฐ 1
------------------------
๋ง์ง๋ง ์กฐ๊ฑด์ ๋ณด๊ณ ์ง๋ฉ๋๋ก (?) ๊ฒฐ๊ณผ๊ฐ ๋์๋ฒ๋ฆฌ๊ธฐ ๋๋ฌธ์
2,3๋ฒ์ ๊ฐ๋ค ์กฐ๊ฑด์ ๋ฃ์ด์ฃผ๋ฉด์ ํ์ด์ผํ๋ค.
๊ฐ๋ค ์กฐ๊ฑด์ ๋ฃ์ด์ฃผ๊ฒ๋๋ฉด ๋ง์ง๋ง ์กฐ๊ฑด์ด ๋ฉ๋๋ก ์ถ๋ ฅ๋์ง์๋๋ค.
1) Y1 < Y2
2) Y1 == Y2 && M1 < M2
3) Y1 == Y2 && M1 == M2 && D1 < D2
class Solution {
public int solution(int[] date1, int[] date2) {
int answer = 0;
if (date1[0] < date2[0])
answer = 1;
if (date1[0] == date2[0] && date1[1] < date2[1])
answer = 1;
if(date1[0] == date2[0] && date1[1] ==
date2[1] && date1[2] < date2[2])
answer = 1;
return answer;
}
}
[์คํจ]
ํ ์คํธ 1238 ์ด ์คํจํ๋ค. ใ ใ
class Solution {
public int solution(int[] date1, int[] date2) {
int answer = 0;
if (date1[0] < date2[0] )
answer = 1;
if (date1[1] < date2[1])
answer = 1;
if(date1[2] < date2[2])
answer = 1;
return answer;
}
}
class Solution {
public int solution(int[] date1, int[] date2) {
int answer = 0;
//data1 data2 ?? ๋
๋ ์ ์ผ ์์ผ๋ก ๋น๊ต
for (int i = 0 ; i< date1.length; i++){
if (date1[i] < date2[i]){
answer = 1; break;
}
}
return answer;
}
}