Binary Search Iterative Problem
Binary Search Iterative Problem — ExecCode Easy DSA Practice
Solve the Binary Search Iterative problem on ExecCode. Free online easy DSA practice in Binary Search. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given the input needed to solve Binary Search Iterative. Your task is to a search space contains many possible answers. In Binary Search Iterative, the challenge is to narrow that space intelligently instead of trying every possibility blindly. nums, target (see starter). Index or -1. Return the required answer exactly as shown in the examples.
Examples
Input {"nums": [1, 2, 3, 4, 5], "target": 3}; Output 2. Input {"nums": [2, 5, 7, 8, 11, 12, 15], "target": 13}; Output -1. Input {"nums": [5], "target": 5}; Output 0
Constraints
1 <= len(nums) <= 10^4
Practice Binary Search Iterative free on ExecCode. Browse DSA problems, topic map, and placement guides.