Before starting your test, we highly recommend that you explore the platform and customize your settings for an optimal experience.
Explore the Platform
Familiarize yourself with the platform by taking the sample test in the invite email.
Customize Your Environment
You can adjust the platform settings to match your preferences:
- Switch between light and dark mode based on your visual comfort.
- Choose your preferred editor emulation (e.g., Vim, Emacs).
- Enable or disable auto-complete.
Answering a Coding Question
Here is a quick video walkthrough on how to solve a Coding Question:
Or, if you prefer to follow directions, here are the steps:
- Choose your programming language from the Language dropdown.
- Use the given code editor to write your answer.
- To avoid compilation and syntax errors and make effective use of your test time, use the IntelliSense-like code autocomplete capability in the editor. You can use this functionality only if the test setter has allowed it for your test. This functionality is subject to availability given that the test setter can choose to disable it.
- Click Run Code to execute your solution against the sample test cases.
- Click Run Tests to check if your solution passes the hidden test cases.
- Debug your code using debug print statements or using the Custom Inputs option.
- When you're ready, press Submit at the bottom of the edit window to save your work and return to the question selection page. The Solve button will now display as Modify. As long as the test section remains available and you haven't submitted the entire test, you can return to the challenge to make changes.
Guidelines
Solving a Coding Question
When solving coding questions on HackerRank, all inputs are received from standard input (STDIN), and outputs are sent to standard output (STDOUT). Most of the questions come with a code stub that handles reading and writing values. Your task is to complete the function or class provided.
Editing and Running Code
You can view the top and bottom code stubs by clicking the arrow next to them. These stubs are usually non-editable. If a code stub is not present, a link to information about handling STDIN and STDOUT will be provided.
Note: Changing the programming language resets the code editor. If you start coding in the wrong language, copy your code, switch the language, and paste your code into the new editor.
Flexibility in Coding
You have the flexibility to customize your solution. You can rename variables, write helper functions, or convert lists to arrays as needed. Just ensure that the function signature, your work, and the footer code together form a syntactically correct script. These scripts are typically executed in an Ubuntu environment using standard interpreters and compilers.
Testing your Code
Most questions require you to return a value. If you include print statements (e.g., console.log in JavaScript) in a challenge that requires a return value, these print statements will be directed to a "Debug Output" window and will not affect your score. However, if the challenge requires printed output rather than a return value, debug statements will cause your solution to fail, so remember to remove them before submitting.
Each coding challenge includes sample and hidden test cases:
- Sample Test Cases: These allow you to verify the general logic of your code.
- Hidden Test Cases: These include edge cases designed to test the correctness and efficiency of your algorithm. If your solution is too slow, you may encounter a "time limit exceeded" error. In that case, consider optimizing your algorithm. Hidden test cases are marked with a lock icon. The input and expected output for these cases are not shown—only your function's output and debug information are visible.
For additional testing, you can create custom tests by selecting the "Custom Test" checkbox at the bottom of the edit window. Follow the format described in the "Input Testing for Custom Testing" section.
Note: Scoring is based on exact string matching, so your output must match the expected result exactly.
Refer to the following topics for detailed information about debugging code in your test:
Refer to the following topics for detailed information on: