
Asked in Swiggy
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!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Swiggy
Q. Subsequences of String Problem Statement You are provided with a string 'STR' th...read more
Q. Unique Binary Search Trees Problem Statement Given an integer 'N', your task is ...read more
Q. Count Ways To Travel Triangular Pyramid Bob is given a triangular pyramid with v...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Swiggy Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

