Skip to main content

61 docs tagged with "Binary Search"

View all tags

Binary Search

This is a solution to the Binary Search problem on LeetCode.

Find Peak Element

A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array. You must write an algorithm that runs in O(log n) time.

Find the Duplicate Number

Given an array of N + 1 size, where each element is between 1 and N. Assuming there is only one duplicate number, your task is to find the duplicate number.

Floor in a Sorted Array Problem (gfg)

This tutorial covers the solution to the Floor in a Sorted Array problem from the GeeksforGeeks website, featuring implementations in Python and C++.

Friends Of Appropriate Ages

Calculate the total number of friend requests made between persons based on their ages, following specific conditions that determine when a friend request is not sent.

Heaters

This is a solution to the heaters problem on LeetCode.

House Robber IV

This is a solution to the House Robber IV problem on LeetCode.

Min Stack

Given the sorted rotated array nums of unique elements, return the minimum element of this array.

My Calendar I

This is a solution to the My Calendar I problem on LeetCode.

Patching Array

This document provides solutions for the Patching Array problem.

Peak Index in a Mountain Array

Find the index of the peak element in a mountain array (an array that increases to a peak and then decreases) in O(log(n)) time complexity.

Single Element in a Sorted Array

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element that appears only once.

Smallest Rectangle Enclosing Black Pixels

Given an image represented by a binary matrix where 0 is a white pixel and 1 is a black pixel, return the area of the smallest rectangle that encloses all black pixels. The black pixels are connected, and the rectangle must be axis-aligned.

Sorted Array Search

This tutorial covers the solution to the Sorted Array Search problem from the GeeksforGeeks website.

Split Array With Same Average

This document provides a solution where we split an array into two non-empty subsets such that both subsets have the same average.