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
1y

The task is to determine the number of levels cleared by Kevin based on the total number of hurdles he has jumped.

  • Each level 'i' has 'i' hurdles, so Kevin can only reach level 'i' if he has cleared le...read more

Help your peers!
Add answer anonymously...
Rupeek Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter