Coding Solved: Google Coding Competitions Runtime Error (RE) Issue (JAVA)

Solved: Google Coding Competitions Runtime Error (RE) Issue (JAVA)

-

Google hosts a bunch of coding contests every year, some of which are Code Jam, Kickstart and Hash Code. Google uses the same web IDE in each of its contests where you need to write your code and submit it. But if you’re using it for the first time ever, no matter which coding contest you’re participating in or practising for, there’s a high chance that the IDE will tell you that your program encountered a runtime error.

The error message simply says “Sample Failed: RE“. And even when you click on the eye button, it says “RE“, which means Runtime Error. It does not provide any further info regarding why the error occurred. And the most surprising thing is, in most cases, your code will run fine in any other IDE other than Google’s Coding Competition IDE.

Google Coding Competition Runtime Error

I too came across this problem some time ago and even after visiting many forums, I didn’t find the answer. But then, the idea struck my mind and I finally solved the Runtime Error in my Google Kickstart Code. This solution to fix the runtime error will work in all Google Coding Competitions, e.g. Code Jam, Kickstart and Hash Code.

How To Fix The Runtime Error In Google Code Jam/Kickstart/Hash Code

Well, this problem is caused by nothing but your program’s class name.

Google follows a convention where you must always define the Main class of your program (the class that contains the main method) as “public class Solution“.

Runtime Error Fixed

Thus, to fix the runtime error issue, all you gotta do is, rename your class declaration to “public class Solution”

This is a weird convention set by Google. The more annoying part is that it is nowhere mentioned about this convention and thus programmers like I and you spend hours looking for the reason why the compiler is throwing us a Runtime Error even though the other compilers are running it perfectly.

I hope this article helped you solve the Runtime Error issue. Do let me know in the comments section below if there’s any other problem that you’re facing with the Google Coding Contests IDE. I will try my best to help you out!

Do check out some other posts on my site for more cool stuff! Have a great day ahead!

Anirban Roy
Anirban Roy is the founder of TechRBun. He is a Computer Geek. He likes to share his knowledge about PC, Mobiles and Blogging. He studies in class XII and when he is not studying, he can always be found tweaking his PC or surfing the web on his mobile phone. He loves music and literature too!

13 COMMENTS

  1. Thank you so much, this works. And it’s pretty weird why would Google set such conventions. But that’s how it is… Anyways thanks for discussing it in detail.

    • This kind of false error doesn’t happen in the case of Python. If you’re facing a runtime error in Python, that’s most probably due to a real mistake in your code.

      • I have tested the same code on codechef, repl, and geeksforgeeks and it ran fine on every site except for google competition website. That’s why I am saying it.

          • https://ide.geeksforgeeks.org/syp9meGSoe
            The input I am taking here is the same as the sample input given in the question in kickstart round D today. Here the code is working fine. But there it is showing “Sample Failed: RE”.

          • Yeah, I see it now. This seems to be another undiscovered bug of Google Coding Platform that is generating false Runtime Errors. This article is dedicated to Java. However, thanks for informing me that this problem is occurring with Python as well. I will do some more research on this and publish a new article on that topic separately. You will be notified via an e-mail in case the solution is found. However, if you find the solution to that problem before, you can mail it to [email protected] and your solution will be posted on this website, with full credits going to you. Thanks.

  2. i already named my class as “Solution” but still i am facing this issue. my java code runs on any other online compiler but it shows RE on kickstart. can you help me with this?

    my code is attached below.
    https://docs.google.com/document/d/1vx-mXGwRlrSRyVuMZSy4VlX5CV2lbWkYnfywtjy39sw/edit?usp=sharing

    • Hi Mustansir,

      There’s a REAL ERROR in your code. You are trying to store an int value in an array without specifying the index, which is causing the error.
      Please take a look at the picture given below for your reference.

      Google Kickstart Runtime Error Issue Solved

  3. I renamed the class name as Solution still i’m getting RE, while same code is producing correct answer on gfg and codechef for sample test cases

  4. hello.. I have my program running perfectly and also my class name is “Solution”. What is the issue with the code now?

    import java.util.*;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;

    public class Solution
    {
    public static void main(String []args)
    {
    Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int test=sc.nextInt();
    if(test>=1 && test<=100){
    for(int t=1;t<=test;t++)
    {
    int n=sc.nextInt();
    int b=sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i=0)
    {
    b=b-arr[i];
    count++;
    i++;
    }

    return count-1;
    }
    }

    • Hi Tripti,
      Your code has the following two errors:
      1. On line 17, the for loop is invalid. The syntax for a for loop in Java is for(initialization;condition;changes). Although you can skip one or more parameters, but the two semicolons are mandatory, however, your code misses a semicolon after the second parameter.
      2. On line 23, I believe you forgot to end the outer for loop. The compiler cannot parse your code properly due to the missing closing bracket.

      Take a look at the picture below for reference:

      Google coding contest error solution

LEAVE A REPLY

Please enter your comment!
Please enter your name here

You might also likeRELATED
Recommended to you