New Experience
Before you begin your test, take the sample test provided in your invitation email. This helps you become familiar with the HackerRank platform and practice solving coding questions.
Navigating the platform
Use the following options to navigate between questions and customize your workspace:
- Select the side navigator to switch between questions. Click Home to return to the test dashboard.
- Click the Expand icon to enlarge the coding area. Click the Collapse or Question icon to resize the coding area and display the question panel.
Writing code using Monaco Editor
HackerRank uses the Monaco Editor, a web-based code editor developed by Microsoft and used in Visual Studio Code. The platform currently uses version 0.50.0. The editor supports multiple programming languages and provides an integrated environment for writing and testing code.
Key features
The Monaco Editor includes the following features:
-
Multi-language support: Supports more than 60 programming languages.
-
IntelliSense:
- Autocompletion and contextual suggestions for functions, variables, and keywords in over 20 languages.
- Real-time diagnostics for errors and warnings.
- Language-specific syntax highlighting.
- Autocompletion and contextual suggestions for functions, variables, and keywords in over 20 languages.
-
Customization options:
-
Editor mode: Choose from the following editor styles:
-
Normal: Default setting for general use.
-
Emacs: Mimics Emacs behavior for users familiar with its shortcuts and commands.
-
Vim: Mimics Vim behavior for users who prefer its navigation and editing features.
-
Normal: Default setting for general use.
-
Tab spaces: Choose the number of spaces for indentation:
-
2 spaces: Compact and minimal; common in modern coding styles.
-
4 spaces: Standard setting for most programming languages; provides balanced readability.
-
8 spaces: Used in legacy codebases requiring wider spacing.
-
2 spaces: Compact and minimal; common in modern coding styles.
-
Autocomplete: Enable or disable real-time suggestions for functions, variables, and syntax.
-
View code diff: Compare your current code with the last saved or submitted version.
-
Revert: Track and restore earlier versions of your code.
-
Live collaboration: Allows multiple users to edit code simultaneously in real time.
-
Editor mode: Choose from the following editor styles:
-
Run: Executes the code against multiple test cases to validate correctness. You can:
- Run individual test cases.
- Use custom test cases with your own input.
- Toggle between formatted and raw output views.
- Reposition the output panel by clicking the Dock icon.
- Run individual test cases.
-
Submit: Submit your final solution for evaluation.
Platform limitations
The coding environment has the following limitations:
-
Debugging support: Limited debugging capabilities are available.
-
Advanced IDE features: No support for advanced terminal access and extensible plugin.
-
Browser support: Use one of the following supported versions or newer:
-
Chrome: Version 94+
-
Firefox: Version 93+
-
Safari: Version 16.4+
- Edge: Version 94+
-
Chrome: Version 94+
Guidelines for solving coding questions
Follow these guidelines to solve coding questions successfully.
Solving the problem
All input is read from standard input (STDIN), and output is written to standard output (STDOUT). Most questions provide a code stub that handles input and output. Complete the provided function or class.
Editing the code
Use the arrow next to the top or bottom code stub to expand and view them. These sections are read-only. If no stub is provided, a link is available to guide you on manually handling STDIN and STDOUT.
Note: Switching the programming language resets the code editor. To avoid losing your work, copy your code before switching and paste it into the new editor.
You can customize your code by:
- Renaming variables.
- Creating helper functions.
- Converting between data structures.
Ensure that your function signature, implementation, and footer code together form a syntactically valid script. Code runs in an Ubuntu environment using standard interpreters or compilers.
Testing the code
Most questions require your function to return a value. If you use print() statements (such as console.log in JavaScript), the output appears in the Debug Output panel and does not impact your score.
Important: If the question expects printed output, remove all debug print statements before submitting. Debug output may cause your solution to fail validation.
Each challenge includes the following test cases:
-
Sample test cases: Validate basic logic of your solution.
-
Hidden test cases: Include edge cases to test correctness and performance of your code. .
- These are marked with a lock icon.
- The input and expected output are hidden.
- Only your output and debug logs are shown.
- These are marked with a lock icon.
Note:
- If your solution runs slowly, try optimizing your algorithm to prevent time limit errors.
- Scoring is based on exact string matching. Your output must exactly match the expected result.
Troubleshooting
If you encounter an issue:
- Check the FAQs for common solutions.
- If the issue persists, click Help to report the problem.
Related topics
- Debugging the Logic in Functions
- Debugging a complete program
- Modifying Code Submissions in a Test
- Auto Saving Functionality of Coding Questions in a Test
Existing Experience
Before starting your test, we highly recommend exploring the platform and customizing 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.
Navigating the platform
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 effectively use 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.
Writing code using Monaco Editor
HackerRank uses Monaco Editor which is a web-based code editor developed by Microsoft that powers Visual Studio Code. We are currently on version 0.50.0. The Monaco Editor is a robust code editor that supports various programming languages and offers a rich environment for coding and testing, making it ideal for developers attempting a coding question on HackerRank. This is supported in Tests and Interviews.
Key Highlights
-
Multi-Language Support
- Supports 60+ programming languages.
-
IntelliSense
- Autocompletion and contextual suggestions for functions, variables, and keywords are available for 20+ languages.
- Real-time error and warning diagnostics.
- Provides clear, language-specific syntax coloring.
- Customizations Available:
-
Editor Mode (Normal, Emacs, Vim)
- Allows users to select their preferred editor style.
- Normal: Default editor behavior suited for general usage.
- Emacs: Mimics the Emacs editor, favored by users familiar with its shortcuts and commands.
- Vim: This mimics the Vim editor, offering modes like command and insert. It is ideal for developers accustomed to Vim’s powerful navigation and editing features.
- Allows users to select their preferred editor style.
-
Tab Spaces (2, 4, 8)
- Lets users adjust the number of spaces used for indentation.
- 2 spaces: Compact and minimal, used in some modern coding styles.
- 4 spaces: The standard for most programming languages, providing balanced readability.
- 8 spaces: Legacy or strict standards where wide spacing is required.
- Lets users adjust the number of spaces used for indentation.
-
Autocomplete (Enable/Disable)
- Toggles the auto-suggestion feature. Offers real-time suggestions for functions, variables, and syntax as you type, helping reduce typos and coding errors.
-
View Code Diff
- Compare the current code with the last saved or submitted version.
- Compare the current code with the last saved or submitted version.
You can also use the advanced Revert feature to track changes made during debugging or enhancement phases, as it highlights added, removed, or modified lines. You can choose to restore these versions
-
Keybindings Support
- Allows key mappings, similar to popular IDEs like Visual Studio Code.
- Collaborative Features in Interview
- Allows real-time collaboration with multiple users to edit the code simultaneously.
-
Run and Submit:
- Run Code: Allows testing the solution with a sample input to check basic correctness.
- Run Tests: Executes the code against multiple test cases to validate correctness comprehensively.
- Submit: Submit the final solution for evaluation.
Limitations
-
Debugging Support
- While the Editor provides IntelliSense, debugging capabilities are limited(none).
-
Advanced IDE Features
- It lacks features like advanced terminal access and extensive plugin ecosystems compared to our full-fledged multi-file IDEs, such as VS Code and Jupyterlab.
-
Browser Support
- The Editor is supported only on versions mentioned above For optimal performance, ensure that your browser meets or exceeds the following version requirements:
- Chrome: Version 94 or newer
- Firefox: Version 93 or newer
- Safari: Version 16.4 or newer
- Edge: Version 94 or newer
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. Ensure that the function signature, your work, and the footer code 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. You may encounter a time limit exceeded error if your solution needs to be faster. 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.
You can create custom tests by selecting the Custom Test checkbox at the bottom of the edit window for additional testing. 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: