DrawCode Practice Problem

Binary Search

Given a sorted array `nums` and `target`, return the index of `target` or `-1` if not found.

Examples

Input

nums = [-1,0,3,5,9,12], target = 9

Output

4

Input

nums = [-1,0,3,5,9,12], target = 2

Output

-1

Constraints


Interactive Visualizer Workspace

Explore step-by-step interactive animations, memory state tracking, and live multi-language execution in DrawCode.

Launch Interactive Visualizer