๐ Algorithm/PGS
[ํ๋ก๊ทธ๋๋จธ์ค] Lv.0 ๋์ด ์ถ๋ ฅ (Java)
devussy
2023. 2. 22. 17:19
๐ก ๋ฌธ์
๋จธ์ฑ์ด๋ 40์ด์ธ ์ ์๋์ด ๋ช ๋ ๋์ ํ์ด๋ฌ๋์ง ๊ถ๊ธํด์ก์ต๋๋ค. ๋์ด age๊ฐ ์ฃผ์ด์ง ๋, 2022๋ ์ ๊ธฐ์ค ์ถ์ ์ฐ๋๋ฅผ return ํ๋ solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
๐ ๋ด ๋ต์
import java.time.*;
class Solution {
public int solution(int age) {
LocalDate today = LocalDate.now();
return today.getYear() - age + 1;
}
}
class Solution {
public int solution(int age) {
int answer = 0;
if ( age>0 && age <=120)
answer = 2022 - age;
return answer + 1;
}
}