JAVA 첫 번째
class Solution {
public int solution(int M, int N) {
int answer = 0;
answer = (M-1) + (N-1) * 2;
return answer;
}
}
JAVA 두 번째
class Solution {
public int solution(int M, int N) {
int answer = 0;
answer = (M * N) -1;
return answer;
}
}
OR
class Solution {
public int solution(int M, int N) {
int answer = 0;
if (M < N) {
answer += M-1;
answer += (N-1)*M;
} else {
answer += N-1;
answer += (M-1)*N;
}
return answer;
}
}
class Solution {
fun solution(M: Int, N: Int) = (M*N) -1
}
OR
import kotlin.math.*
class Solution {
fun solution(M: Int, N: Int)= (max(M,N) - 1) + max(M,N) * (min(M,N) - 1)
}