Jam's story

[프로그래머스] 종이자르기 java 본문

코딩테스트/프로그래머스

[프로그래머스] 종이자르기 java

애플쩀 2022. 12. 12. 06:40
class Solution {
    public int solution(int M, int N) {
 	        int answer = 0;
	        if (M<0  || N<0) return 0;
	        answer+=M-1;
	        answer+=M*(N-1);
	        return answer;
    }
}

 

다른사람풀이 

class Solution {
    public int solution(int M, int N) {
        return M - 1 + (N - 1 ) * M;
    }
}
Comments