Treasure Hunt Problem Statement
Alex and Rome are engaged in a treasure hunt game. Rome has a treasure box that Alex aims to open, using one of the N uniquely numbered keys placed by Rome in boxes numbered sequentially from 1 to N. Alex knows the key number needed to open the treasure box but not the box containing this key. Additionally, Alex is aware that for a given box 'i', the key number there is greater than all key numbers in any previous box 'j' (where j < i).
Objective:
Given the list of key numbers, your task is to help Alex determine the box number containing the correct key, or indicate that the correct key is not present in any box.
Example:
Input:
T = 1
N = 3, K = 15
key = [5, 10, 15]
Output:
3
Explanation:
The correct key number is found in box number 3.
Constraints:
1 <= T <= 10
1 <= N <= 10^4
1 <= K <= 10^9
1 <= key[i] <= 10^9
for each boxi
- The pattern
key[i] > key[j]
for alli > j
holds true.
Note:
Your implementation should not print anything. Just implement the required function to achieve the solution.
Top WatchGuard Technologies Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Reviews
Interviews
Salaries
Users/Month