It is often the basic, simple things that make a big difference between average programmers and great ones. The best programmers have a very deep understanding of the fundamentals of programming and know its applications, inside and out.
For an average programmer to get here, it will involve a lot of practice, and HackerEarth is going to help you with that.
Introducing HackerEarth Code Monk
This will be a bi-weekly contest - one on Tuesday and other on Thursday. Problems will be based on basic computer science concepts. Every week, we will release a tutorial, on which the Code Monk challenge will be based on. A week after the release of the tutorial, the Code Monk challenge will be conducted.
The aim is simple - learn the concepts, and put them to use. Do this repeatedly, and you will be well on your way to becoming a master computer programmer!
Also, top 3 newbie programmers will get HackerEarth T-shirts in each Code Monk challenge!
Note - Participants of this Code Monk Arrays and Strings will be automatically registered for the rest of the Code Monk Series
Can I participate in a sample challenge?
Yes, we recommend that you participate in our sample challenge.
This challenge enables you to understand how to pa...more
Can I participate in a sample challenge?
Yes, we recommend that you participate in our sample challenge.
This challenge enables you to understand how to participate in programming challenges on HackerEarth. It comprises detailed information about how programming questions should be attempted and details about the HackerEarth judge.
1. Where will the challenge take place?
This challenge is an online challenge.
2. Will I receive a reminder notification before the challenge begins?
You will receive a reminder e-mail 3 hours before the challenge begins only if you have registered for the challenge.
3. How do I participate in this challenge?
To participate in this challenge, do the following:
a. Register for the challenge
b. Visit the challenge page on start date/time
c. Click Participate in Challenge
4. What type of questions will I have to solve in this challenge?
The questions in this challenge are of the following types:
Write code in the online code editor that is provided with each problem and submit it.
You can make multiple submissions. The platform automatically considers the best submission.
Multiple choice questions (MCQ)
Questions with multiple choices will be provided.
You should select the correct answer from the list of choices.
Instructions for each problem differ
Enter the solution in the text area that is provided and submit it
5. Are the programming questions restricted to specific languages?
The languages that you can write code in will be mentioned in the challenge details, if applicable.
6. What will happen in case of there is an issue with my computer or Internet connection?
If there is an issue with your computer or your Internet connection, you will not lose your previously submitted answers. They will be saved on HackerEarth's servers. You can log in again and continue coding from where you stopped.
However, the timer will continue running, which is why it is advised that you ensure that your computer/Internet connection is working properly before you begin the challenge.
7. My code works in my local IDE, however, it throws compilation errors when I run it on the platform interface. Why does this happen?
Every problem has the following two buttons:
a. Compile & Run
When you click Compile & Run, the is tested against the sample input and output.
This ensures that you are able to test your code against predefined sample test cases before you submit your code.
When you click Submit, the code is checked extensively against internal test cases. The following parameters are considered while checking the code:
Time limit: The code should run within the stipulated time otherwise it will throw a Time Limit Exceeded (TLE) error.
Memory limit: The code should run within the give memory size otherwise it will throw a Memory Limit Exceeded (MLE) error.
Errors during runtime: Specific test cases check for Runtime Errors (RE) only.
Correct answer: If your answer is incorrect, then you will see the message Wrong Answer (WA) on the screen. This means that your program is not printing he correct answer. Ensure that your program conforms with the output format that is required.
8. Is it possible to change my submission after I have submitted a task?
Yes, you can edit and submit the solution to a question (that you can view and edit) any number of times before the challenge-completion time window closes.
Note: Some tests have timed sections. After the time limit is reached, you will not be able to revisit questions in that section.
9. How does the online judge determine whether a solution is correct?
An online judge is a code checker and not a human being. The code checker or "judge" tests your code automatically. Therefore, you must write your code accordingly.
For each problem, based on the specifications mentioned in the problem statement, there will be one or more input files and corresponding (correct) output files. The program that you create is run on each of the input files and the corresponding output must match the (correct) output files in order.
Your program will be marked incorrect in the following cases:
Output files (generated by running your code) do not match the pre-generated output files
Output files (generated by running your code) matches all the pre-generated output files, however, it is not in the order in which the pre-generated output files are arranged
10. How does the time limit work?
Your program must read, process, and output the result for all input files within the specified time limit.
The input file will be of the format that is specified in the problem. This means that if each input file contains multiple test cases, then your code must pass all the test cases within the specified time limit.
11. How does the total execution time work?
Your code is tested multiple times against different input files. The displayed execution time is the total time spent executing each input file. Hence, Total execution time <= (Time Limit * Number of input files)
Your program is terminated in the following scenarios:
If the time that is required to execute each input file exceeds the time limit execution that is set for any input file.
If the total time that is required to execute all the input files exceeds the total time limit allowed.
12. How does the total memory consumed work?
The total memory consumed by a program is the sum of the memory that is consumed by the program in stack, data, heap, and BSS. To understand more about the address space of a program and the memory consumed, refer to this image or this explanation.
13. My program doesn't compile. Why?
Ensure that you are using a compiler that complies with the standards.
For example, do not use Turbo C++. Code that compiles in Turbo C++ will often not compile on the online judge.
Also, remove 'conio.h includes' in your code.
We support multiple classes and inner static classes.
Your code may throw errors if the inner classes are not static.
Please note that we will remove this constraint very soon. We will update you when this happens.
The compilation errors that you see on the screen are self-explanatory.
However, if you require any more information, please contact us at email@example.com.
14. Does TLE error mean that my code is correct but slow?
No, Time Limit Exceeded or TLE means that your solution has exceeded the amount of time that is allowed for problem execution or for a specific test case. Your solution never finished running in time and it was stopped in between. There is no definite way to know whether the code was correct.
15. What does Wrong Answer (WA) mean?
WA means that your program ran successfully but gave an incorrect answer. This could mean either of the following:
Your program contains a bug
You have not interpreted the problem text correctly
Apart from the sample input, your code will also be evaluated against multiple input and output cases. Therefore, even if your code passes the sample input correctly, it may not have passed one of the other input and output cases because of the answer is incorrect.
16. Why is my submission queued?
Your submission is queued because of simultaneous submissions by multiple users. You will receive the result of your submission in real-time as soon as it is processed.
17. My submissions are not evaluated. What should I do?
There may be an issue with the online judge due to which your submissions are not being evaluated. Send an e-mail to firstname.lastname@example.org.
18. Will I receive the results of the challenge? If yes, when?
You can view your ranking on the leaderboard for all challenges in which participation is not confidential. This leaderboard is updated in real-time.
19. Where can I view the solutions for the problems of this challenge?
Once the challenge is finished and the problem has been moved to a practice section, you can view the solutions (editorials) in the Practice section.
20. Why am I seeing a runtime error on the screen?
A runtime error means that the program was compiled successfully but it crashed or exited with an error. The most common error messages include the following:
|1||SIGSEGV||Segmentation fault error||Caused by an out-of-scope array index causing a buffer overflow, an incorrectly initialized pointer, etc.
Signal is generated when a program tries to read or write outside the memory that is allocated for it, or to write memory that can only be read.
For example, you are accessing a[-1] in a language which does not support negative indices for an array.
|2||SIGXFSZ||Output limit exceeded error||Your program has printed too much data to output.|
|3||SIGFPE||Floating point error||This usually occurs when you're trying to divide a number by 0, or trying to take the square root of a negative number.|
|4||SIGABRT||Raised by the program||This happens when the judge aborts your program in the middle of execution.
This can also be raised due to insufficient memory.
|5||NZEC||Non-zero exit code error||This message means that the program exited to the shell by returning a value that is different from 0.
For languages such as C/C++, this probably means you forgot to add "return 0" at the end of the program.
It could happen if your program threw an exception which was not caught. Trying to allocate too much memory in a vector.
For interpreted languages like Python, NZEC will usually mean that your program either crashed or raised an uncaught exception.
Some of the reasons being in such cases would be: the runtime errors mentioned above. Or, for instance usage of an external library which is causing some error, or not being used by the judge.
|6||MLE||Memory limit exceeded error||This error means that your program tried to allocate memory beyond the memory limit indicated.
This can occur if you declare a very large array, or if a data structure in your program becomes too large.
|7||OTHER||Generated when you use too much memory||Check for arrays that are too large, or other elements that could grow to a size too large to fit in memory.
Sometimes it can also be generated for reasons similar to the SIGSEGV error.
Avoiding runtime errors
Ensure that you are not using variables that haven't been initialized. These may be set to 0 on your computer, but aren't guaranteed to be on the judge.
Check every single occurrence of accessing an array element and see if it could possibly be out of bounds.
Ensure that you are not declaring too much memory. 64 MB is guaranteed, but having an array of size  will never work.
Ensure that you are not declaring too much stack memory. Any large arrays should be declared globally, outside of any functions - putting an array of 100000 ints inside a function probably will not work.