AIOPBINA - Simple Search
TIME LIMIT IS IN FACT 0.3 SECONDS, please ignore the info on the side
Given a sorted array A of size N and an element K, find if K exists in the array.
You need to solve for T test cases.
PLEASE IMPLEMENT A BINARY SEARCH, don't cheese the problem due to the small data and loose time limit
Input
The first line of input contains an integer T, the number of test cases.
In each test that follows, there will be 2 lines.
The first line contains integers N and K.
The next line will be N integers separated by a space.
Output
For each of the T testcases, output YES or NO after you determine if K exists in the array.
Constraints
1 <= T <= 15
1 <= N <= 10^5
1 <= K <= 10^5
0 <= A[i] <= A[i + 1] <= 10^5 for all i from 0 to N - 1
Example
Input: 2 5 10 1 4 7 10 20 6 13 1 4 6 7 8 23
Output: YES NO
Added by: | OuiOuiBaguette |
Date: | 2024-07-27 |
Time limit: | 0.300s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |