Skip to main content

Posts

Showing posts with the label java. Hackerrank

Cats and a Mouse Hackerrank Solution - java

Cats and a Mouse Hackerrank Solution - java For Explanation Watch Video: Code:: 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 {     // Complete the catAndMouse function below.     static String catAndMouse(int x, int y, int z) {         int aCat = Math.abs(z-x);         int bCat = Math.abs(z-y);         if(aCat==bCat){             return "Mouse C";         }else if(aCat<bCat){             return "Cat A";         }else{             return "Cat B";         }     }     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")));         int q = scanner.nextInt();         scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");         for (in