---
title: Test case format
description: This article contains information about test cases in programming questions and sample test cases for a sample programming question.
---

[Skip to content](https://help.hackerearth.com/hc/en-us/articles/9810665517081-test-case-format#main-content)

English

Show submenu for translations

![HE logo.png\]](https://help.hackerearth.com/hs-fs/hubfs/HE%20logo.png?height=40&name=HE%20logo.png)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://help.hackerearth.com/?hsLang=en)
2. [Assessments: Recruiters](https://help.hackerearth.com/assessments-recruiters?hsLang=en)
3. [Programming](https://help.hackerearth.com/assessments-recruiters?hsLang=en#programming)

# Test case format

## This article contains information about test cases in programming questions and sample test cases for a sample programming question.

### Type of test cases required

Every programming question needs test cases. At HackerEarth, we recommend a minimum of 10 test cases that cover various corner cases for a specific problem statement. The format of the test case file should follow the given condition:

- There must be exactly 10 test cases for each problem.
- The total score of the test cases must be 100.
- Suppose the answer to any problem is a single integer or a single character, then it must have multiple test cases.
- The size of an individual test case should not exceed 8 MB.

These test cases can be divided as follows:

#### Easy test cases

Easy test cases should meet these conditions.

| **Features of the test case** | **Example** | **Score** |
| --- | --- | --- |
| Add two Easy test cases. Recommendation: The first two Easy test cases should be made visible to candidates | If you have an array with size n equal to 10^5 constraints, then your n value should be less than equal to 10. **Problem Constraint** ![](https://help.hackerearth.com/hs-fs/hubfs/undefined-2.png?width=97&height=19&name=undefined-2.png) **Test Case Constraint** ![](https://help.hackerearth.com/hs-fs/hubfs/undefined-3.png?width=91&height=16&name=undefined-3.png) | If the total score of your question is 100, then your Easy test cases should have a score of 5 each **Example** - Test Case 1: 5 Marks - Test Case 2: 5 Marks |
| The constraint size should be minimal as possible |  |  |
| The brute force approach can be used to solve the test case |  |  |
| A candidate should be able to solve this test case manually |  |  |

#### Medium test case

Medium test cases should meet these conditions.

| **Features of the test case** | **Example** | **Score** |
| --- | --- | --- |
| Add three Medium test cases | If you have an array with size n equal to 10^5 constraints, then your n value should be less than equal to 10^3 **Problem Constraint** ![](https://help.hackerearth.com/hs-fs/hubfs/undefined-Jun-01-2023-10-49-20-5703-AM.png?width=97&height=19&name=undefined-Jun-01-2023-10-49-20-5703-AM.png) **Test Case Constraint** ![](https://help.hackerearth.com/hs-fs/hubfs/undefined-4.png?width=97&height=19&name=undefined-4.png) | If the total score of your question is 100, then your Medium test cases should have a score of 5 each **Example** - Test Case 3: 5 Marks - Test Case 4: 5 Marks - Test Case 5: 5 Marks |
| These test cases should cover corner cases related to the algorithm being used |  |  |
| A candidate should be able to solve these test cases in the most optimal manner. For example, a Greedy Algorithmic approach can be used to solve the test case. |  |  |

#### Hard test cases

Hard test cases should meet these conditions.

| **Features of the test case** | **Example** | **Score** |
| --- | --- | --- |
| Add five Hard test cases | If you have an array with size n equal to 10^5 constraints, then your n value should be less than equal to 10^5. **Problem Constraint** ![](https://help.hackerearth.com/hs-fs/hubfs/undefined-Jun-01-2023-10-50-17-1765-AM.png?width=97&height=19&name=undefined-Jun-01-2023-10-50-17-1765-AM.png) **Test Case Constraint** ![](https://help.hackerearth.com/hs-fs/hubfs/undefined-Jun-01-2023-10-50-17-1765-AM.png?width=97&height=19&name=undefined-Jun-01-2023-10-50-17-1765-AM.png) | If the total score of your question is 100, then your Hard test cases should have a score of 15 each **Example** - Test Case 6: 15 Marks - Test Case 7: 15 Marks - Test Case 8: 15 Marks - Test Case 9: 15 Marks - Test Case 10: 15 Marks |
| These test cases are aimed at checking if candidates can solve the problem in the most optimal manner |  |  |
| The constraint size should be as exhaustive as possible |  |  |
| Only the correct algorithm or approach can be used to solve the test case |  |  |

### Generating test cases

Generate test cases that are compatible with the [auto-generated code snippets](https://help.hackerearth.com/hc/en-us/articles/360002884553-code-snippets?hsLang=en). For example, assume that you are creating test cases for this problem statement: 

**Write a program to find the highest/maximum number in an array.**

#### Sample input and sample output

The input and output for this problem statement will be as follows:

![](https://help.hackerearth.com/hs-fs/hubfs/undefined-Jun-01-2023-10-51-17-8549-AM.png?width=416&height=343&name=undefined-Jun-01-2023-10-51-17-8549-AM.png)

### Explanation

- Here 10 in the first line of the sample input signifies the number of elements in the array
- The second line of the sample input signifies 10 elements in the array, separated by spaces
- The sample output only contains the answer that is the highest/maximum number in the array

So, go through the auto-generated code snippets first and then generate the test cases accordingly so that you don’t have to change the auto-generated code snippets afterward.

This is how you can easily create test cases for programming questions for various difficulties.

#### Solution for the example problem in C++

![](https://help.hackerearth.com/hs-fs/hubfs/undefined-Jun-01-2023-10-51-18-1203-AM.png?width=375&height=555&name=undefined-Jun-01-2023-10-51-18-1203-AM.png)

### Code to create random test cases in C++ in your local system

![](https://help.hackerearth.com/hs-fs/hubfs/undefined-Jun-01-2023-10-51-17-9798-AM.png?width=624&height=547&name=undefined-Jun-01-2023-10-51-17-9798-AM.png)

- [Assessments: Recruiters](https://help.hackerearth.com/assessments-recruiters?hsLang=en#main-content)

    - [Getting started](https://help.hackerearth.com/assessments-recruiters?hsLang=en#getting-started)
    - [Account settings](https://help.hackerearth.com/assessments-recruiters?hsLang=en#account-settings)
    - [Admin management](https://help.hackerearth.com/assessments-recruiters?hsLang=en#admin-management)
    - [Creating tests automatically](https://help.hackerearth.com/assessments-recruiters?hsLang=en#creating-tests-automatically)
    - [Creating tests manually](https://help.hackerearth.com/assessments-recruiters?hsLang=en#creating-tests-manually)
    - [Test settings](https://help.hackerearth.com/assessments-recruiters?hsLang=en#test-settings)
    - [Sections and question pooling](https://help.hackerearth.com/assessments-recruiters?hsLang=en#sections-and-question-pooling)
    - [Libraries](https://help.hackerearth.com/assessments-recruiters?hsLang=en#libraries)
    - [Multiple Choice Questions (MCQs)](https://help.hackerearth.com/assessments-recruiters?hsLang=en#multiple-choice-questions-mcqs)
    - [Programming](https://help.hackerearth.com/assessments-recruiters?hsLang=en#programming)
    - [Project](https://help.hackerearth.com/assessments-recruiters?hsLang=en#project)
    - [SQL](https://help.hackerearth.com/assessments-recruiters?hsLang=en#sql)
    - [Data science](https://help.hackerearth.com/assessments-recruiters?hsLang=en#data-science)
    - [Machine Learning (ML)](https://help.hackerearth.com/assessments-recruiters?hsLang=en#machine-learning-ml)
    - [DevOps](https://help.hackerearth.com/assessments-recruiters?hsLang=en#devops)
    - [Python project questions](https://help.hackerearth.com/assessments-recruiters?hsLang=en#python-project-questions)
    - [Automation Testing](https://help.hackerearth.com/assessments-recruiters?hsLang=en#automation-testing)
    - [Java Project](https://help.hackerearth.com/assessments-recruiters?hsLang=en#java-project)
    - [C# project questions](https://help.hackerearth.com/assessments-recruiters?hsLang=en#c-project-questions)
    - [Subjective](https://help.hackerearth.com/assessments-recruiters?hsLang=en#subjective)
    - [Approximate](https://help.hackerearth.com/assessments-recruiters?hsLang=en#approximate)
    - [Diagram](https://help.hackerearth.com/assessments-recruiters?hsLang=en#diagram)
    - [File upload](https://help.hackerearth.com/assessments-recruiters?hsLang=en#file-upload)
    - [Invites](https://help.hackerearth.com/assessments-recruiters?hsLang=en#invites)
    - [Reports](https://help.hackerearth.com/assessments-recruiters?hsLang=en#reports)
    - [Billing](https://help.hackerearth.com/assessments-recruiters?hsLang=en#billing)
    - [HackerEarth Reports: Admins, Tests, and Teams](https://help.hackerearth.com/assessments-recruiters?hsLang=en#hackerearth-reports-admins-tests-and-teams)
    - [Technical Content Updates](https://help.hackerearth.com/assessments-recruiters?hsLang=en#technical-content-updates)
- [FaceCode](https://help.hackerearth.com/facecode?hsLang=en#main-content)

    - [FaceCode and its features](https://help.hackerearth.com/facecode?hsLang=en#facecode-and-its-features)
    - [Scheduling interviews on FaceCode](https://help.hackerearth.com/facecode?hsLang=en#scheduling-interviews-on-facecode)
- [Assessments: ATS integrations](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#main-content)

    - [Integration](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#integration)
    - [iCIMS](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#icims)
    - [Zoho Recruit](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#zoho-recruit)
    - [SmartRecruiters](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#smartrecruiters)
    - [EightFold](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#eightfold)
    - [SuccessFactors](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#successfactors)
    - [Greenhouse](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#greenhouse)
    - [Lever](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#lever)
    - [Linkedin Talent Hub](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#linkedin-talent-hub)
    - [JazzHR](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#jazzhr)
    - [Workable](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#workable)
    - [Recruiterbox - Trakstar Hire](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#recruiterbox-trakstar-hire)
    - [Jobvite](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#jobvite)
    - [Ashby](https://help.hackerearth.com/assessments-ats-integrations?hsLang=en#ashby)
- [Assessments: Product updates](https://help.hackerearth.com/assessments-product-updates?hsLang=en#main-content)

    - [Release notes: HackerEarth Assessment](https://help.hackerearth.com/assessments-product-updates?hsLang=en#release-notes-hackerearth-assessment)
    - [Root Cause Analysis (RCA)](https://help.hackerearth.com/assessments-product-updates?hsLang=en#root-cause-analysis-rca)
    - [Content updates](https://help.hackerearth.com/assessments-product-updates?hsLang=en#content-updates)
- [Assessments: Best practices](https://help.hackerearth.com/assessments-best-practices?hsLang=en#main-content)

    - [Recruit](https://help.hackerearth.com/assessments-best-practices?hsLang=en#recruit)
- [SSO](https://help.hackerearth.com/sso?hsLang=en#main-content)

    - [SSO](https://help.hackerearth.com/sso?hsLang=en#sso)
- [Upskilling](https://help.hackerearth.com/upskilling?hsLang=en#main-content)

    - [Introduction: Upskilling](https://help.hackerearth.com/upskilling?hsLang=en#introduction-upskilling)
- [Assessments: Candidates](https://help.hackerearth.com/assessments-candidates?hsLang=en#main-content)

    - [Getting started](https://help.hackerearth.com/assessments-candidates?hsLang=en#getting-started)
    - [Test environment](https://help.hackerearth.com/assessments-candidates?hsLang=en#test-environment)
    - [Question types](https://help.hackerearth.com/assessments-candidates?hsLang=en#question-types)
    - [FaceCode](https://help.hackerearth.com/assessments-candidates?hsLang=en#facecode)
    - [Feedback and queries](https://help.hackerearth.com/assessments-candidates?hsLang=en#feedback-and-queries)
- [Problem setting for HackerEarth](https://help.hackerearth.com/problem-setting-for-hackerearth?hsLang=en#main-content)

    - [Rate cards](https://help.hackerearth.com/problem-setting-for-hackerearth?hsLang=en#rate-cards)
- [Campus](https://help.hackerearth.com/campus?hsLang=en#main-content)

    - [Recruiters](https://help.hackerearth.com/campus?hsLang=en#recruiters)
    - [Recruiter FAQs](https://help.hackerearth.com/campus?hsLang=en#recruiter-faqs)
    - [Candidate FAQs](https://help.hackerearth.com/campus?hsLang=en#candidate-faqs)
- [Hackathons and Hiring Challenges](https://help.hackerearth.com/hackathons-and-hiring-challenges?hsLang=en#main-content)

    - [Hackathons](https://help.hackerearth.com/hackathons-and-hiring-challenges?hsLang=en#hackathons)
    - [Hiring challenges](https://help.hackerearth.com/hackathons-and-hiring-challenges?hsLang=en#hiring-challenges)
- [Frequently Asked Questions (FAQs)](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#main-content)

    - [Assessments: Recruiters](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#assessments-recruiters)
    - [GDPR compliance (Candidates)](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#gdpr-compliance-candidates)
    - [GDPR compliance (Recruiters)](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#gdpr-compliance-recruiters)
    - [General](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#general)
    - [Assessments: Candidates](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#assessments-candidates)
    - [HackerEarth Vs ChatGPT](https://help.hackerearth.com/frequently-asked-questions-faqs?hsLang=en#hackerearth-vs-chatgpt)
- [Profiles](https://help.hackerearth.com/profiles?hsLang=en#main-content)

    - [Profiles - Recruiter](https://help.hackerearth.com/profiles?hsLang=en#profiles-recruiter)
- [OnScreen](https://help.hackerearth.com/onscreen?hsLang=en#main-content)

    - [OnScreen - Interview templates](https://help.hackerearth.com/onscreen?hsLang=en#onscreen-interview-templates)
    - [OnScreen - Sending Invites](https://help.hackerearth.com/onscreen?hsLang=en#onscreen-sending-invites)
    - [OnScreen - Download reports](https://help.hackerearth.com/onscreen?hsLang=en#onscreen-download-reports)
    - [OnScreen - Interview Analytics](https://help.hackerearth.com/onscreen?hsLang=en#onscreen-interview-analytics)
    - [OnScreen - Overview](https://help.hackerearth.com/onscreen?hsLang=en#onscreen-overview)
    - [OnScreen - Interview Proctoring Settings](https://help.hackerearth.com/onscreen?hsLang=en#onscreen-interview-proctoring-settings)

[![Chill listening crop-3](https://help.hackerearth.com/hs-fs/hubfs/HE%20Logo%20for%20sig-1.png?width=120&height=24&name=HE%20Logo%20for%20sig-1.png "Chill listening crop-3")](https://www.hackerearth.com/)

Copyright © 2026, HackerEarth