Arkadipta Kunduarkadiptakundu.hashnode.dev·Sep 1, 2024The Ultimate Guide to Using Binary Search on Rotated and Repeated Arrays !Binary search is a fundamental algorithmic technique used to efficiently locate elements in a sorted array. It is always used when the array is sorted. But what do you do if there are multiple elements in that array or the array is sorted but rotated...Discuss·10 likesBinary Search Algorithm
Dhruv Chouhandestroycompiler.hashnode.dev·Jul 30, 2024Binary Search - perfect_0Binary search is one of the most important algorithms of the world. This guide is for complete beginners and will help you understand and implement the binary search algorithm in code. It will explain the intuition behind binary search and teach you...Discuss·51 likes·304 readsBinary Search Algorithm
Chetan Dattachetan77.hashnode.dev·Jul 22, 2024Matrix MedianProblem Given a row wise sorted matrix of size R*C where R and C are always odd, find the median of the matrix. (link) Example 1: Input: R = 3, C = 3 M = [[1, 3, 5], [2, 6, 9], [3, 6, 9]] Output: 5 Explanation: Sorting matrix elements giv...DiscussLeetcodeMatrix-Median
Chetan Dattachetan77.hashnode.dev·Jul 21, 20241901. Find a Peak Element IIProblem A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom. Given a 0-indexedm x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j...DiscussLeetcode1901. Find a Peak Element II
Chetan Dattachetan77.hashnode.dev·Jul 21, 2024240. Search a 2D Matrix IIProblem Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in each column are sorted i...DiscussLeetcodesearch-a-2d-matrix-ii
Chetan Dattachetan77.hashnode.dev·Jul 20, 202474. Search a 2D MatrixProblem You are given an m x n integer matrix matrix with the following two properties: Each row is sorted in non-decreasing order. The first integer of each row is greater than the last integer of the previous row. Given an integer target, retur...DiscussLeetcodesearch-2d-matrix
Chetan Dattachetan77.hashnode.dev·Jul 20, 2024Find the row with maximum number of 1'sProblem Given a boolean 2D array, consisting of only 1's and 0's, where each row is sorted. Find the 0-based index of the first row that has the maximum number of 1's. Return the 0-based index of the first row that has the most number of 1s. If no su...DiscussLeetcodeFind the row with maximum number of 1's
Vineeth Chivukulavineethchivukula.hashnode.dev·Jun 28, 2024Solving Binary SearchTo see the question, click here. Naive Approach The idea is to search the entire array to find the target. So, if the target is found, return the index; otherwise, return -1. // TC: O(n) // SC: O(1) public class BinarySearch { public int search(...DiscussBinary Search Algorithm
Vineeth Chivukulavineethchivukula.hashnode.dev·Jun 24, 2024Understanding the Modified Binary Search TechniqueModified binary search is a versatile technique used to efficiently search for elements in sorted arrays or lists or solve problems that involve finding a specific value or condition in a sorted context. The standard binary search algorithm is modifi...DiscussBinary Search Algorithm
Chetan Dattachetan77.hashnode.dev·May 13, 2024Kth element of 2 sorted arraysProblem Given two sorted arrays arr1 and arr2 of size N and M respectively and an element K. The task is to find the element that would be at the kth position of the final sorted array. Example 1: Input: arr1[] = {2, 3, 6, 7, 9} arr2[] = {1, 4, 8, 10...DiscussLeetcodekth-element-of-2-sorted-arrays