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 box i
  • The pattern key[i] > key[j] for all i > j holds true.
Note:

Your implementation should not print anything. Just implement the required function to achieve the solution.

Be the first one to answer
Add answer anonymously...
WatchGuard Technologies Software Developer Intern 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