FastPrepFastPrep
Problem Brief

Buddies Greater than Target 🦋

OA

Once upon a time, in a realm of integers, there was a quest to find the first spot where the landscape changed dramatically. The adventurers were given a map called "numbers," guiding them through this numerical landscape. Their mission was to discover the very first location where the terrain rose sharply, where three consecutive points, represented by "numbers[i]," "numbers[i + 1]," and "numbers[i + 2]," stood higher than a certain threshold.

As they journeyed through this numerical expanse, they diligently searched for a place where the terrain shifted abruptly, where three consecutive points towered above the threshold. Should they find such a place, they would mark the index "i" and return triumphantly. Yet, if no such spot existed, they would sadly return with news of their quest's failure, marked by a return value of -1.

Their journey was not about speed, but about thorough exploration. So long as their method did not exceed a complexity greater than O(numbers.length2), they could traverse the landscape within the allotted time.

For original prompt, please refer to source image. 🐳

1Example 1

Input
buddyList = [0, 1, 4, 3, 2, 5], target = 1
Output
2
Explanation
At the starting point, index 0, the trio of companions (buddyList[0], buddyList[1], buddyList[2]) includes 0 and 1, neither of which surpasses the threshold of 1. Moving to index 1, the companionship of (buddyList[1], buddyList[2], buddyList[3]) comprises 1, 4, and 3. However, only 4 exceeds the target value. It's not until index 2 that the trio (buddyList[2], buddyList[3], buddyList[4]) emerges, featuring all friends whose values surpass the threshold. Thus, the answer lies at index 2, where the landscape shifts dramatically.

Constraints

Limits and guarantees your solution can rely on.

Unknown for now
public int tDeskGreaterThanThreshold(int[] buddyList, int target) {
    // write your code here
}
Input

buddyList

[0, 1, 4, 3, 2, 5]

target

1

Output

2

Sign in to submit your solution.