In your HackerRank Coding questions, test cases help your interviewer validate your coding logic to address all the different scenarios in a problem and verify your output against the expected output. Test cases can be categorized as Sample and Hidden test cases. Sample test cases are those which are executed first when you run your code. Their purpose is to carry out an initial validation of your coding logic over simple use cases and verify your output against the exact expected output.
Please refer to the Sample Test Cases article to know how sample test cases work.