We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// Complete the solve function below.
static long solve(int n, int m) {
if( n == 1 && m == 1){
return 0;
}else if(n == 1 && m > 1) {
return m-1;
}else if(n > 1 && m == 1){
return n-1;
}else {
return (n*m)-1;
}
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String[] nm = scanner.nextLine().split(" ");
int n = Integer.parseInt(nm[0]);
int m = Integer.parseInt(nm[1]);
long result = solve(n, m);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
bufferedWriter.close();
scanner.close();
}
}
what is wrong with the code??
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cutting Paper Squares
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class Solution {
if( n == 1 && m == 1){
}else if(n == 1 && m > 1) {
}else if(n > 1 && m == 1){
}else {
} what is wrong with the code??