# Welcome to Search Binary Element

This is the contest system for Search Binary Element. The contest has now finished. You can view the final results.

0
Problems
3 / 4
Contestants / Teams
46
Languages
0
Submissions

# Binary Search Challenge

## Problem Description

Implement a binary search algorithm to find a target value in a sorted array of integers.

Write a function `binarySearch(arr, target)` that takes two parameters:

• `arr`: A sorted array of integers in ascending order
• `target`: The integer value to search for in the array

The function should return:

• The index of the target value if it exists in the array
• -1 if the target value is not found in the array

## Input

• The first line contains an integer `n` (1 ≤ n ≤ 10^5), the number of elements in the array.
• The second line contains `n` space-separated integers `a_i` (-10^9 ≤ a_i ≤ 10^9), representing the sorted array.
• The third line contains an integer `q` (1 ≤ q ≤ 10^5), the number of queries.
• Each of the next `q` lines contains a single integer `t_i` (-10^9 ≤ t_i ≤ 10^9), the target value to search for.

## Output

For each query, output a single integer on a new line:

• The index (0-based) of the target value in the array if found
• -1 if the target value is not in the array

## Constraints

• Time limit per test: 3 second
• Memory limit per test: 256 megabytes

## Sample Input

10 -5 -2 0 3 6 9 11 14 18 21 11

6

## Start & End Times

 Start Time 2024-07-20 19:58 CEST End time 2024-07-22 00:58 CEST

## Problems

No problems available.

## Scoring

Partial Credit — Ranked

Explanation:
Standard scoreboard type for problems with partial credit. Participants are ranked by the sum of the score of each problem. There is no tiebreaker.

## Standings

• Standings are shown without limitation.