General FAQ
At HackerRank, we are continually innovating, creating, and designing to give the candidates of our platform the ability to accomplish more. One way we fulfill this objective is by committing to a diverse and inclusive culture in the hiring space. We comply with the WCAG 2.1 AA Standards to make our content accessible to a broader range of candidates with disabilities, including but not limited to blindness, deafness, cognitive limitations, and others.
For more information, check the HackerRank's Approach to Accessibility article.
The test setters at the hiring company design your HackerRank Tests and determine the test schedule and duration.
- Check the test email invite from the recruiter to know the schedule period and the allocated time to complete the test.
- You can also see the duration indicated on the HackerRank test login page. You are expected to complete and submit the answers within this time.
- The timer starts at the moment you log in to the test. As you attempt the questions, keep an eye on the remaining time.
- The timer turns orange when there are only a few minutes left before the test can time out.
HackerRank only provides a platform to conduct the challenges. For help regarding the test schedule, time extension, and evaluation of tests, directly contact the recruiter of the concerned company.
All the work you submitted before losing the internet connection is saved on our servers. After the internet connectivity is resumed, you can log on to the test again (if it is not past the test completion time) and resume answering the questions. The test timer does not stop ticking when you are offline, and the test ends at the scheduled time.
You can request the recruiter who invited you to the test to give you an extension because of the lost time. They can allow additional time for you to complete the test. They can give you a time duration extension to complete the Tests in progress and send you re-invites to retake a Test.
However, it is best to check your computer and internet connection before taking the test. HackerRank only provides a platform to conduct the challenges and cannot allow you extra time to complete the test. For help regarding the test schedule, time extension, and evaluation of tests, directly contact the recruiter of the concerned company.
If you log out or are unintentionally locked out of your account during a test before submitting your code, the same can have the following implications:
- If the test is timed, logging out of the account before clicking Submit leads to auto-submission of the latest code on the candidate's editor.
- Logging out of your account during a test means your test attempt will automatically come to an end.
- If you wish to retake the test, contact the recruiter who invited you to the test directly and request a re-invite.
- You retake a test only if you are re-invited for the test.
Yes. You can navigate freely across the questions and resubmit your solution to any question accessible by clicking on "Submit & Continue" multiple times. Please note that some tests have timed sections, and once a section-time limit is reached, you will not be able to revisit questions in that section. But there is no limit on the number of times you can submit your answer to a question that you can view/edit.
We recommend you go through our Frequently Asked Questions for any technical-related issues.
You can also refer to Candidate Support, where we host many support articles for candidates.
If your queries are not resolved using the available documents or have persistent issues, please get in touch with our support team here.
FAQ related to Errors
The HackerRank for Work test platform allows different candidates to simultaneously log in and attempt their respective tests. Our platform may sometimes experience an unprecedented volume of candidates taking different tests simultaneously.
To ensure a good test experience, the platform has a particular limit on the number of candidates allowed to attempt HackerRank tests at a given instant. In a scenario where the specified limit of test-takers has exceeded the platform, a candidate may not log in to a test.
When the HackerRank test platform is at capacity, the following message is displayed if you're trying to log in to your test. Note the hiring company's scheduled time window for completing the test.
This is usually a temporary situation. We recommend:
- You try again after some time - provided there is sufficient time left in the test schedule. You should be able to log in and start your test when the situation eases on the platform.
- Contact your hiring manager - if the test schedule ends soon and you are running short of time.
- Contact the recruiter or the hiring company who originally sent you the test invitation and inform them about the situation.
- You can open the received test invite email and click "Reply All" to send your query or request to the hiring company's concerned recruiter(s). The hiring firm would typically be included in the email when you click "Reply All," and we'd defer to them to respond to your request.
You can resolve this problem by performing any of the following:
- Refresh your browser tab or window. If a page is refreshed while the test is in progress, it does not affect the test workflow. After the page is refreshed, you return to the same question you were solving. All the previous submissions are retained.
- You can open your session in incognito mode.
- You can empty the cache and cookies to resolve this problem.
- You can log out of the current session and log in again. All the previous submissions are retained in this case.
If you are experiencing slow net speeds, some page components may not load. Such issues are generally solved by refreshing your browser tab/window. Refreshing your browser tab while taking a test will not affect your flow. You will be brought back to exactly where you were, and you can continue solving problems.
At HackerRank, we are continually innovating, creating, and designing to give the candidates of our platform the ability to accomplish more. One way we fulfill this objective is by committing to a diverse and inclusive culture in the hiring space. We comply with the WCAG 2.1 AA Standards to make our content accessible to a broader range of candidates with disabilities, including but not limited to blindness, deafness, cognitive limitations, and others.
For more information, check the HackerRank's Approach to Accessibility article.
FAQ Related to Programming Tests
In the HackerRank Coding tests, the languages option available in the editor lists the different programming languages you can choose from to write your solution. The editor automatically resets and adapts according to the chosen language.
Typically, the test setter at your hiring company determines the programming languages which will be allowed to answer a particular coding problem. This is generally based on the specific skills the company intends to assess in each candidate. Only the permitted programming languages are available to choose from and write your solution.
Example: In your HackerRank Test, assuming you are at a coding question requires you to write the logic to find the first non-repeated character in a string. Your test setter may want to assess your coding skills in C# and Python, and hence, the languages option lists only the C# and Python languages to choose from.
In your tests, for coding questions, you can reuse the initial or original prototypical code, which was populated in the editor for the selected programming language. You can reset your code by simply copying and pasting the original version over your version of the code.
- While viewing a coding question, click the three dots in the upper right of the window; and then select the View code diff option.
-
The resulting window will display the original code provided in the editor for this question.
- You can copy/paste lines using Ctrl/Command + C
- and Ctrl/Command + V from the Original Code (left) to the Modified Code (right).
- The changes you make to the Modified Code will reflect in your editor once you click "Update.".
Note: The code editor periodically saves your code. The editor automatically resets when you choose a different programming language.
In your Coding questions, test cases are the different types of inputs to your code to test your defined logic and produce the output. A test case is termed "passed" when the output from your code exactly matches the expected output. Otherwise, the "Wrong Answer" status is indicated against the test case.
Refer to the following topics for detailed information about test Cases:
- Click Run code to compile your logic and execute all the test cases in the code editor. You can click this button any number of times during a test.
- If permitted in your test, use the "test against custom input" option to validate your logic using your own input values.
Note: When you use the keyboard shortcut command+return to Run Code, the cursor will automatically move to the next line in the code editor. Also, Clicking Run Code does not calculate any scores for the test cases.
Sample test cases are simple validation scenarios to test your logic, whereas the other test cases may cover corner scenarios around the problem. Try to understand the constraints in the problem statement and verify the coding or logical approach in your solution to handle different edge scenarios around the problem. Maybe you're solving a different problem than the question expects you to solve.
These are called "Hidden test cases" and validate your code to cover edge scenarios for the given problem. Through hidden test cases, test setters expect to understand candidates' problem-solving abilities, and therefore, the input and output values are hidden. Candidates are expected to think through the various scenarios around a problem and produce the expected output in test cases.
See Hidden test cases.
If your code works on the local editor but fails on HackerRank, The reason could be one from the below:
- Your code doesn't match the expected output. The output produced by your code must exactly match the output expected by the test case, so something like a spelling error in your output will cause you to fail the challenge.
- You're using a different compiler. Check out our Environment page for up-to-date information on how we're compiling your code.
- Your code's behavior is unpredictable. If you're using C/C++, double-check for uninitialized variables or invalid memory accesses, as they can cause unpredictable behavior. If you overrun an array or attempt to print the contents of an array cell that was never initialized, your output may look like it's correct, but you'll fail the challenge (invisible garbage characters are the worst, we know).
Yes, we have intelligent auto-complete similar to what is found in modern editors such as Eclipse or Visual Studio. Auto-complete will automatically trigger in languages like Java and Python at specific syntax points - like after you type "." in "System.out." You can also trigger it manually at any time using the "Ctrl-Space" key combination.
Check out the Writing State Information to a File article in our knowledge base.
In your HackerRank tests, coding questions have an in-built editor (IDE) and compiler which supports coding in multiple programming languages. When you are solving coding questions, the editor automatically saves your code periodically and also has the following options:
- Run code - Click this button any number of times to compile your code and run test cases. The option first checks for any coding errors and then validates test cases by comparing the output from your code against the expected output. While debugging or after making any code changes, click "Run code" to recompile and retest your solution.
Clicking "Run code" does not evaluate your answer or calculate any scores for the test cases.
- Submit code and Continue - Click to Submit your final answer to a coding problem. You can modify a submission and resubmit your answer any number of times before the test ends. Scores are calculated for the submitted version of your answer in the test.
Note: If your test times out before submitting the final answer, the last compiled version of your code is automatically submitted in the test. Click here for more information.
In the HackerRank coding environment, your coding solution has an execution time limit depending on the chosen programming language. When you run your code, this is the time limit within which your code is expected to read input, process, and return output for all the test cases, failing which, you will see the "Terminated due to timeout" message.
Refer to the HackerRank Coding Environment Specifications Page to know the specific time limit for your chosen programming language, and accordingly, optimize your code for faster execution to achieve the output.
Your test setter expects optimal solutions in coding questions, and therefore, on the HackerRank coding environment, there are preset execution time limits for different programming languages. For example, the Python language has a 10-second time limit as compared to the C language, which has a 2-second execution time limit.
For a detailed understanding, refer to The "Terminated due to timeout" status topic.
In your HackerRank tests, for coding questions, you can download the sample input and output values for reference by clicking the Download sample test cases link as shown below.
The input and output values are downloaded in separate text files, and each contains the values defined in the Sample test cases of the coding question.
The input values are downloaded in raw format. For example, if the input values are array elements, then the input file will contain the array size followed by the array elements as input.
Refer to the Custom input values format topic for detailed information.
Note: You can only download the sample input and output values if your test setter has defined Sample test cases for the coding question.
If you are using Java, C#, or Scala, you have to call your main class Solution. This is essential to get your code to run. Please do not use any package names in your code.
A "Wrong Answer" status in your HackerRank Coding questions implies that your program or code is unable to produce the exact expected output for the Test Cases.
Some common causes of a "Wrong Answer" are listed below:
- A mismatch between the format of your output and the format of the expected output.
- Your solution's inability to handle corner scenarios and provide a complete solution.
- Code formatting and naming guidelines issue.
- Debug output values printed in the "Your Output" area and compared with the expected output.
Refer to the Failed Test Cases or "Wrong Answer" Status topic for detailed information.
It is recommended that you verify your solution for any of the above-mentioned causes and debug your code to identify logical issues.
In HackerRank Tests, you can debug your solution using the following methods:
- Using the "Test against custom input" option to pass custom input values to your code and verifying the output.
- Using the relevant debug print statements or print commands specific to the chosen programming language. Include the print commands and test your outputs at different logical levels. For example, while coding with C++, use the cout<< command to debug your code.
Refer to the following topics for specific information:
In most problems, you would read input from STDIN
(Standard Input) and write output to STDOUT
(Standard Output). Different languages have different methods of accessing STDIN
and STDOUT
. Please refer to the sample codes below for the most common (possibly naive) methods.
This is best explained with a simple problem statement and solutions in different languages.
Problem Statement
Write a program that adds two numbers prints the sum to STDOUT. Read the input from STDIN. The first line of your input will contain an integer (N) that tells you how many more lines there are in the input. Each of the subsequent N lines contains 2 integers). You need to print the sum of each pair on a separate line of STDOUT.
Sample Input
3 1 5 3 10 999 -34343
Sample Output
6 13 -33344
Solution
C
6 #include int main () { int n, i, a, b; scanf("%d", &n); for (i = 0; i < n; ++i) { scanf("%d %d", &a, &b); printf("%d\n", a+b); } }
Solution
C++
6 #include using namespace std; int main() { int n; cin >> n; for(int i = 0; i < n; i++) { int a, b; cin >> a >> b; cout << a+b << "\n"; } return 0; }
Solution
C#
using System; using System.IO; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); for(int t = 0; t < n; t++) { String str = Console.ReadLine(); String[] strArr = str.Split(); int a = Convert.ToInt32(strArr[0]); int b = Convert.ToInt32(strArr[1]); Console.WriteLine(a+b); } } }
Solution
Java
import java.io.*; import java.util.*; class Solution { public static void main(String [] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int t = 0; t < n; t++) { int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a+b); } } }
Solution
Objective C
#import<Foundation/Foundation.h> int main(int argc, const char* argv[]) { @autoreleasepool { NSInteger t; scanf("%lu", &t); for (NSInteger i = 0; i < t; i++) { NSInteger a, b; scanf("%lu %lu", &a, &b); /* * Do not use NSLog to print to stdout */ printf("%lu\n", a + b); } return 0; } }
Solution
Python
n = int(raw_input()) for i in range(0,n): a, b = raw_input().split() print int(a) + int(b)
Solution
Python 3
n = int(input()) for i in range(n): a, b = input().strip().split(' ') print (int(a) + int(b))
Solution
Ruby
n = gets.to_i (0...n).each do |i| lis = gets.strip.split(" ") a = lis[0].to_i b = lis[1].to_i puts a + b end
Solution
PHP
<!?php $handle = fopen ("php://stdin","r"); $t = fgets($handle); for($i=0; $i<$t; $i++) { $lis = explode(" ", fgets($handle)); print((int)$lis[0] + (int)$lis[1]) . "\n"; } fclose($handle); ?>
Solution
Javascript
process.stdin.resume(); process.stdin.setEncoding('ascii'); var __input_stdin = ""; var __input_stdin_array = ""; var __input_currentline = 0; process.stdin.on('data', function (data) { __input_stdin += data; }); process.stdin.on('end', function () { __input_stdin_array = __input_stdin.split("\n"); var res; var n = parseInt(__input_stdin_array[__input_currentline].trim(), 10); __input_currentline += 1; for (var i = 0; i<n;i++) { var _line = __input_stdin_array[__input_currentline].trim(); __input_currentline += 1; var line = _line.split(" "); var _a = parseInt(line[0]); var _b = parseInt(line[1]); res = _a + _b; process.stdout.write(""+res+"\n"); } });
Solution
Clojure
(use '[clojure.string :only (split triml)]) (def n (Integer/parseInt (read-line))) (loop [i 0] (when (< i n) (def a (read-line)) (def new (split a #"\s+")) (println ( + (Integer/parseInt (get new 0)) (Integer/parseInt (get new 1)) )) (recur (inc i)) ))
Solution
Perl
$n = <>; for($i=0; $i<$n; $i++) { $lis = <>; @ll = split(' ', $lis); print $ll[0] + $ll[1]; print "\n"; }
Solution
Haskell
import Control.Monad main :: IO () main = do n <- readLn :: IO Int str <- replicateM n getLine let ans = map (sum. map read. words) str mapM_ print ans
Solution
Erlang
-module(solution). -export([main/0]). main() -> {ok, [N]} = io:fread("", "~d"), test(N). test(0) -> ok; test(N) -> {ok, [A, B]} = io:fread("", "~d ~d"), io:fwrite("~w~n", [(A + B)]), test(N-1).
Solution
Go lang
package main import "fmt" func main() { var n int var a int var b int fmt.Scan(&n) for i := 0; i < n; i++ { var sum int fmt.Scan(&a,&b) sum = a+b fmt.Println(uint(sum)) } }
Solution
Groovy
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) def a,b, res,line def n = Integer.parseInt(br.readLine()) for (int i = 0; i < n; i++) { line = br.readLine() def (_a,_b) = line.split(' ') a = Integer.parseInt(_a) b = Integer.parseInt(_b) res = a+b println res }
Solution
Scala
object Solution extends App { val n = readInt //recommended (1 to n).map(i => readLine.split(" ").map(_.toInt).sum).foreach(println) /* another way for (i <- 1 to n) { val Array(a, b) = readLine.split(" ").map(_.toInt) println(a + b) } */ }
Solution
R
f <- file("stdin") open(f) count = as.numeric(readLines(f, n = 1)) for(i in 1:count) { lines <- readLines(f, n = 1) num <- strsplit(lines, " ")[[1]] sum <- as.numeric(num[1]) + as.numeric(num[2]) write(sum, stdout()) }
Solution
Swift
import Foundation
let t = Int(readLine()!)!
for i in 1...t {
let nums = readLine()!.characters.split(" ").map{Int(String($0))!}
let a = nums[0]
let b = nums[1]
print(a + b)
}
See Front-end, Back-end, Full-stack IDE - FAQs for technical queries related to Front-end, Back-end, or Full-stack assessments.