Steps to Create an Approximate Solution
- Click on the Library tab on the HackerRank for Work home page, and then click on the Create Question button.
- In the Select Question Type dialog box, click on the Approximate Solution question type.
Problem Statement
On the Problem Statement tab, specify the following:
A. Problem Name
- The problem name should be short and should not give any hints to solve the problem.
B. Tags
- (Optional) Select the Tags from the drop-down list or add your custom tag.
- Tags are words or phrases that help with the searchability and organization of your questions. You can add the existing tags or create new tags. Set the difficulty level for your question by associating the tags as Easy, Medium, or Hard. Alternatively, associate custom tags to identify your question by its complexity or its levels.
- When you view your questions in the Library, the associated tags will be indicated for every question. You can use these tags to generate candidate reports and performance graphs.
- Refer to Associating the Tags for Questions for more information.
C. Problem Description
- A good problem statement should comprise a clear and detailed problem description, at least one sample test case with an explanation, and constraints of the problem.
- Click on the Templates option to use the predefined HackerRank's Coding Question template to define your problem clearly.
- Refer to the Defining the Problem Statement: Coding and Database Engineer Questions topic for more information.
D. Interviewer Guidelines
- Interviewer guidelines are for later reference. You can include a rubric about scoring the questions or write solutions to the problems in this section. These can be used by your team while evaluating the test. This step is optional.
Problem Statement
You can also attach a relevant reference file in these sections. Refer, How to Attach a File to a Problem Statement topic for more information.
- Enter the amount of time, you expect candidates to spend on this question.
- Click on the Save & Proceed button.
Note: Interviewer Guidelines are only visible to you and your team members and in the candidate report.
Languages
On the Languages tab, follow the below instructions:
- Click on the Clear all option so that the candidates can select the checkboxes to solve the problem in any selected language.
Allowed Programming Languages
- In the Code Stub section, specify the function name, and return type, and it is optional to add function parameters and then click on Generate Code to generate the code stub. Refer to the article on Code Stubs for more information.
Generating Code Stubs
- A dialog box is displayed that lists the languages for which auto-generated code stub is not supported.
Programming Languages for which Code Stubs not Supported
Note: This dialog box is only displayed if your allowed languages include one or more unsupported languages for automatically generated code stub.
- In the displayed dialog box, you can either choose to deselect the unsupported languages for automatically generated code stub or retain these languages and then click on the Yes, Generate Code button.
- If you deselect the languages, then those languages are not allowed for answering this question. If you keep these languages, you have to manually select the language in the Default Stub section and type the code stub.
- In the Default Stub section, you can select the languages from the drop-down menu to see the generated code stub.
- Click on the Save & Proceed button.
Test Cases
On the Test Cases tab, perform one of the following actions:
- If you want to add test cases one by one, click on the Add test case button. In the Add Test Case dialog box:
-
-
- Specify the Name of the test case.
- Select the Difficulty level of the particular test case.
- Enter a Score for this test case. If the code passes this particular test case, this score is assigned. The sum of scores of all test cases is the total score assigned to a coding question.
- Specify the Input and expected output values for the test case.
- Optional: Select the Mark as sample test case check box if you want this case to be a sample test case.
- Repeat the steps to add more test cases.
-
Adding Test Cases
Note: You must assign a score to a particular test case, depending on the difficulty level of the test case.
Defining Test Cases to Validate the Code
- Refer to the Defining Test Cases for Coding Questions article for more information on test cases.
- Click on the Upload as .zip button to upload multiple test cases.
-
-
- In the Upload test cases dialog box, click on the Choose file button to upload a zip file that contains test cases from your local system.
-
Click on the Upload button to upload the zip file.
-
Click on the Upload as .zip button.
-
Note: This method is preferred when either the size of input and output is large, or the number of test cases is large. The input files in the zip are named input000.txt, input001.txt, and so on. The output files are named output000.txt, output001.txt, and so on.
- Click on the Advanced settings option to add additional data source files or to enable network access for the questions. You can enable the network access by ticking the Enable network access for the question checkbox.
- Click on the Upload solution button to add a solution for this problem to help candidates debug and see the expected output for their custom input.
- Click on the Save question button to save the question and exit.
- Alternatively, click on the Save & add another button to save this question and proceed to create another one.
Advanced Settings, Upload Solution, and Save Question
- The questions you create are stored in the HackerRank Library under the “My Company questions” section. The question type and the associated tags are indicated below every question title as shown below.
Coding Question in the Library
Custom Checker
-
On the Custom Checker page, write a custom checker code in the editor.
A custom checker is a piece of code written by the problem setter to evaluate test case results and provide custom scoring logic.
Refer to the Creating a custom checker article to understand more details about custom checkers.
- Click on the Save Question button to save the question and exit. Alternatively, click on the Save & Add another button to save this question and add another question.
Quality Review
In the Quality Review section, you can review and add test cases or sample test cases, modify the code stubs, and add more tags.
- Click on the Try question button
Try Question
- In the opened code editor, scroll down and select the check-box Test against custom input to add your custom input.
- Click on the Run Code button to check the status of whether the code has passed or failed the compilation.
Run Code with Custom Inputs
- Click on the My Company Questions tab to view your company questions.
The Questions you create are stored in the HackerRank Library under the “My Company questions” section. The Question type and the associated tags are indicated below every question title. While in the library, you can proceed to create more questions or add questions to your tests.