Frequently Asked Questions

All my solutions in the code editor suddenly went missing. How can I retrieve my solutions?

The code you typed into the code editor is stored temporarily in your browser session, however all your submitted solutions were stored permanently.

Fear not, just click on the "code" icon to retrieve your last submitted code.

Where to find all my submitted code?

Go to the submissions page, then click on the status of that submission row to view more details such as your submitted code.

submission guide
What are the environments for the programming languages of OJ?
Language Version Notes
C++ g++ 6.3
Java java 1.8.0
Python python 2.7.12
Python3 Python 3.5.2
MySQL mysql-server 5.5.44
C gcc 5.4.0 For hash table operations, you may use uthash.
"uthash.h" is included by default.
C# mono 5.0.1.1 Run with --debug flag.
JavaScript nodejs 6.6.0 Run with --harmony flag, enabling new ES6 features.
underscore.js library is included by default.
Ruby ruby 2.2.5
Bash bash 4.3.30
Swift swift 3.1.1
Go go1.8.1 linux/amd64
Scala Scala 2.11.6
I encountered Wrong Answer/Runtime Error for a specific test case. When I test my code using this test case, it produced the correct output as shown below. Why?
runcode result inconsistent

First, please check if you are using any global or static variables. They are Evil, period. If you must declare one, reset them in the first line of your called method or in the default constructor. Why? Because the judger executes all test cases using the same program instance, global/static variables affect the program state from one test case to another. See this Discuss thread for more details.

Are you using C or C++? If the answer is yes, chances are your code has bugs in it which cause one of the earlier test cases to trigger an undefined behavior. See this Discuss thread for an example of undefined behavior. These bugs could be hard to debug, so good luck. Or just give up on C/C++ entirely and code in a more predictable language, like Java. Just kidding.

Am I allowed to print something to stdout?

Yes. You may print to stdout for debug purposes and it will not affect the judgment of your solution. However, doing so will most likely increase the runtime of your program and you may get Time Limit Exceeded or Output Limit Exceeded due to too much extraneous output.

What does [1,null,2,3] mean in binary tree representation?

The input [1,null,2,3] represents the serialized format of a binary tree using level order traversal, where null signifies a path terminator where no node exists below. StefanPochmann made an interesting tree visualizer tool. Check out some examples below.

  1. []
    Empty tree. The root is a reference to NULL (C/C++), null (Java/C#/Javascript), None (Python), or nil (Ruby).
  2. [1,2,3]
           1
          / \
         2   3
  3. [1,null,2,3]
           1
            \
             2
            /
           3
  4. [5,4,7,3,null,2,null,-1,null,9]
           5
          / \
         4   7
        /   /
       3   2
      /   /
     -1  9
What is the difference between 'Time Limit Exceeded' and 'Timeout'?

If your solution is judged 'Time Limit Exceeded', it could be:

  1. Your code has an underlying infinite loop.
  2. Your algorithm is too slow and has a high time complexity.
  3. The data structure you returned is in an invalid state. For example, a linked list that contains a cycle.

On the other hand, 'Timeout' simply means the server queue is busy and could not process your submission for the time being. Please wait for about 10 seconds and submit again.

I messed up in the code editor and would like to start from scratch on a particular problem. How do I reset to the default code definition?

Just click on the reset button to reset your code.

I need to start another round of coding practice. Is there a way to reset the checkmarks of all solved problems?

Yes. Just go to the Session Management panel and activate a new session. Your previous session will be saved and you will start fresh. Your progress will now be tracked separately in the newly created session.

Your blog used to have great explanation of the questions and solutions. I am unable to find it anymore. Did you remove them? Is the blog archived somewhere? Can we have access that? Is it possible to bring it back?

No, it is not removed. All articles were migrated to http://articles.leetcode.com. All old links will automatically be redirected to articles.leetcode.com, for example: http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html

  Send Feedback