The problem statement is an integral part of creating any Question. Particularly, for the coding and database related Questions, a good problem statement should comprise a clear and detailed problem description, supporting data schema, at least one sample test case with an explanation, and constraints of the problem.
HackerRank for Work simplifies this process for you with predefined templates to describe your Coding and Database Engineer type Questions. The templates are a simple and structured format for you to define your Questions clearly.
It is recommended that you use these templates to define your Coding and Database Engineer type Question's problem statement, as it provides a structured and clear view of the Question to your Candidates during Tests and CodePair interviews.
How to Define a Problem Statement
- You must have a HackerRank for Work account.
- While creating a Question, in the Problem Statement page, navigate to the Problem Description field
- On the extreme right of the toolbar, click on the Templates icon.
The following templates are available for selection:
|HackerRank's Coding Question Template||
Recommended for Coding type Questions. Provides the format to define the:
|HackerRank's Database Question Template||
Recommended for Database Engineer type Questions. Provides the format to define the:
- Select the required template based on your Question type. The template format is added to your Problem Description area.
- Detail the Question as per the format.
Write a program that reads in a string and finds the first non-repeated character in that string. Treat the characters as case sensitive. Therefore, "a" and "A" are different. You will be required to complete a given function nonRepeated.
Char nonRepeated(char * str)
There is one sentence in the input that contains String Str.
Sample Test Case with Explanation
A single character that represents the first character in Str that is not repeated.
Recommended Practices to Define a Problem
- Variable naming convention:
- The variables in the problem statement must match those in the code stubs. If you refer to a variable in the problem statement as "N", it should be referred to as "N" (and not "n") in the code stubs as well.
- All variable names and function names should be italicized. For instance, nonRepeated is italicized in the above example.
- Terminology Usage: Be specific and clear when you write a problem statement to avoid any ambiguity. For example: When you have to refer to “binary search tree”; do not use “tree” or “binary tree”, but instead use the "binary search tree" phrase.
Input and Output format
- To ensure a smooth experience for the candidates, you must specify the input and output format with clarity while defining the problem statement.
- Unless you want the candidates to figure out all possible constraints of a problem, you should mention these constraints clearly.
For example: If the code has to read a number as an input, specify the range of that number. This will help the candidate to decide if int, long int, or long long int has to be used. If the input is a string, specify if the special characters such as ? @ , . ^ % are also present in the string. You can also specify if it contains consecutive spaces.
- Sample Test Case with Explanation
- A sample test case, with input and expected output, is strongly recommended to explain the problem statement to the candidates with clarity.