Login

All Problems

Problem title

Difficulty

Avg time to solve

STRING DA MUQABLA

Moderate

30 mins

Boxes and chocolates

Ninja

55 mins

Split A String In Balanced Strings

Easy

15 mins

Ninja And The Nested Ranges

Moderate

25 mins

Minimum Number Of Swaps For Bracket Balancing

Moderate

15 mins

Find Student

Easy

10 mins

Replace Each Element Of Array With Its Corresponding Rank

Easy

10 mins

Special String

Moderate

25 mins

Compare Versions

Moderate

--

Binomial Coefficient Problem

Easy

15 mins

Problem

Submissions

1

Avg. time to solve

10 min

Success Rate

60%

Problem Statement

```
| height[i] - height[i+1] | <= K, where i ∈ (1, N-1)
```

```
Positions are counted starting from 0.
If two or more students have height equal to 'H', return the student with the minimum position.
```

```
The first line contains 'T', denoting the number of tests.
For each Test :
The first line contains three space-separated integers 'N', 'K' and 'H', denoting the number of students, the maximum difference in adjacent heights, and height of target student, respectively.
The second line contains an array 'A' of length 'N', denoting the heights of students.
```

```
For each test, print an integer, denoting the minimum position of a student having a height equal to 'H'.
```

```
You are not required to print the expected output. It has already been taken care of. Just implement the function.
```

```
1 <= 'T' <= 5
1 <= 'N' <= 10^5
1 <= K, A[i] <= 10^9 i ∈ (1, N)
Note - Sum of 'N' over all test cases does not exceed 10^5.
Time Limit: 1 sec
```

```
2
5 1 6
4 5 6 7 6
3 2 2
1 2 2
```

```
2
1
```

```
For case 1:
The first student with height equal to 6, is standing at position 2 (starting from 0).
For Case 2:
The first student with height equal to 2, is standing at position 1 (starting from 0).
```

```
2
3 1 2
1 1 1
4 1 2
3 2 1 3
```

```
-1
1
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code