GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • rulcode
  • Sign In

This view

  • Original page
  • New address

GeezerVison is showing rulcode.com — Binary Search Visualizer & Solution | Rulcode

Fetching algorithms...

    Binary Search Visualizer & Solution | Rulcode
    Loading problem details...

    4. Binary Search

    Easy
    Topics
    Hint

    Understand Before Coding

    Visualize This Problem
    Open Visualizer
    Draw Your Approach
    Draw

    Example 1:

    Input: nums = [-1,0,3,5,9,12], target = 9
    Output: 4
    Explanation: The target 9 is found at index 4 in the array.

    Example 2:

    Input: nums = [-1,0,3,5,9,12], target = 2
    Output: -1
    Explanation: The target 2 is not found in the array, so -1 is returned.

    Example 3:

    Input: nums = [2,5], target = 5
    Output: 1
    Explanation: The target 5 is found at index 1.

    Example 4:

    Input: nums = [5], target = 5
    Output: 0
    Explanation: The target 5 is found at index 0.

    Example 5:

    Input: nums = [2,5], target = 0
    Output: -1
    Explanation: The target 0 is not in the array.

    Constraints:

    • •
    • •
    • •
    • •

    Time Complexity

    O(log n)

    Space Complexity

    O(1)

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.