Hurdle Game Problem Statement

Kevin is playing a hurdle game where he must jump over hurdles to clear levels. Each level ‘i’ consists of ‘i’ hurdles (e.g., Level 6 has 6 hurdles).

Given the total number of hurdles Kevin has jumped, determine how many levels he has cleared.

Input:

The first line contains an integer ‘T’, the number of test cases.
Each test case contains an integer ‘N’, representing the total number of hurdles jumped by Kevin.

Output:

For each test case, output an integer denoting the number of levels Kevin has cleared.
Print the result for each test case on a separate line.

Example:

Input:
T = 1
N = 6
Output:
3
Explanation:

Kevin can clear levels as follows:
Level 1: 1 hurdle
Level 2: 3 hurdles (1+2)
Level 3: 6 hurdles (1+2+3)
Kevin has jumped 6 hurdles in total, so he has cleared 3 levels.

Constraints:

  • 1 <= T <= 50
  • 0 <= N <= 10^8
  • Time limit: 1 sec
AnswerBot
4mo

Given the total number of hurdles Kevin has jumped, determine how many levels he has cleared.

  • Iterate through levels while subtracting hurdles from total jumped until remaining hurdles are less than cu...read more

Help your peers!
Select
Add answer anonymously...

Swiggy Software Developer interview questions & answers

A Software Developer was asked Q. Subsequences of String Problem Statement You are provided with a string 'STR' th...read more
A Software Developer was asked Q. Unique Binary Search Trees Problem Statement Given an integer 'N', your task is ...read more
A Software Developer was asked Q. Count Ways To Travel Triangular Pyramid Bob is given a triangular pyramid with v...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. Subsequences of String Problem Statement You are provided with a string 'STR' th...read more
A Software Developer was asked Q2. Unique Binary Search Trees Problem Statement Given an integer 'N', your task is ...read more
A Software Developer was asked Q3. Count Ways To Travel Triangular Pyramid Bob is given a triangular pyramid with v...read more
Swiggy Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits