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
Be the first one to answer
Add answer anonymously...
Top Swiggy Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app