# Defining the Problem Details: Coding and Database Engineer Questions

_Last updated: Dec 24, 2024, 4:33 AM (Last updated 1 year ago)_

## Overview

The problem details are 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 problem constraints.

HackerRank for Work simplifies this process with predefined templates to describe your **Coding** and **Database Engineer** type questions. The templates are a simple and structured format to define your questions clearly.

It is recommended that you use these templates to define your Coding and Database Engineer type question problem details because it provide a structured and clear view of the question to your candidates during Tests and Interviews.

## How to Define a Problem Statement?

**Steps**

1. While creating a question, navigate to the **Problem Details** field on the **Question Details** page.

2. On the extreme right of the toolbar, click on the **Use content templates** option.



The following templates are available for selection:

Template

Description

HackerRank's Coding Question Template

Recommended for coding-type questions. Provides the format to define the:

problem statement

function

constraints

sample input values

sample output values

HackerRank's Database Question Template

Recommended for Database Engineer-type questions. Provides the format to define the:

problem description with any database queries

the database tables schema

the input using the sample table schema

the output values



*Selecting a template*

1. You can select the required template based on your question type. The template format is added to your **Problem description** area.

2. Detail the question as per the format.



*A coding question description using a coding template*

***For example****:*

Problem Description

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.

Function Description

Char nonRepeated(char * str)

Constraints

The length of the string is less than 256 characters.

It is guaranteed that there will be at least one non-repeated character in the given string

Input Format

There is one sentence in the input that contains String Str.

Sample Test Case with Explanation

Sample Input

balloonbA

Sample Output

a

Explanation

"a" is the first character that is not repeated in the given string.

Output Format

A single character that represents the first character in Str that is not repeated.

## Recommended Practices to Define a Problem

1. Problem Description

- **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 writing a problem statement to avoid 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.

1. Input and Output format

- To ensure a smooth experience for the candidates, you must clearly specify the input and output format while defining the problem statement.

1. Constraints

- 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 the special characters such as:**? @ , . ^ %** are also present in the string. You can also specify if it contains consecutive spaces.

1. Sample Test Case with Explanation

- A sample test case, with input and expected output, is strongly recommended to clarify the problem statement to the candidates.