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.

AnswerBot
4mo

Given a list of key numbers in sequentially numbered boxes, help Alex determine the box containing the correct key.

  • Iterate through the list of key numbers and compare each with the target key number.

  • U...read more

Help your peers!
Select
Add answer anonymously...

WatchGuard Technologies Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. Party Over: Sorting Strings Problem Help Ninja sort the provided list of strings...read more
A Software Developer Intern was asked Q. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
A Software Developer Intern was asked Q. Treasure Hunt Problem Statement Alex and Rome are engaged in a treasure hunt gam...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. Party Over: Sorting Strings Problem Help Ninja sort the provided list of strings...read more
A Software Developer Intern was asked Q2. Covid Vaccination Distribution Problem As the Government ramps up vaccination dr...read more
A Software Developer Intern was asked Q3. Treasure Hunt Problem Statement Alex and Rome are engaged in a treasure hunt gam...read more
WatchGuard Technologies Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits