Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Foobar Error: Error compiling the code, please try again later [closed]

I am getting an error in this program for finding the missing elements in two arrays, I'm new to Java.

package com.google.challenges; 
public class Answer {
    public static int answer(int[] x, int[] y) { 
        for (int n : x)  {
            if (!isPresent(n, y)) {
                return n;
            }
        }
        for (int n : y) {
            if (!isPresent(n, x)) {
                return n;
            }
        }
         return 0;
     }
     private static boolean isPresent(int n, int[] b){
        for (int i : b) {
            if (n == i) {
                return true;
            }
        }
        return false;
    }
}
like image 620
Joel K Thomas Avatar asked Jun 25 '26 12:06

Joel K Thomas


1 Answers

I was also getting this error message. I believe there is problem on Google's end that is not allowing Java code to compile. I have seen other reports of this issue.

Here is my evidence for the issue's lying with Google: replacing all of the code in the method answer with simply return 0; removes all doubt about whether errors in the code are causing it. In this case, the barely-altered skeleton code should successfully compile, the tests should run, and the tests should fail (unless the correct result is 0). Instead, an error message is displayed: "Error compiling the code, please try again later."

The only solution I found was to do it in Python. When I started the challenges, I knew Java and did not know Python, but it was extremely easy to switch.

like image 90
mitch Avatar answered Jun 27 '26 01:06

mitch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!