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
Chetan Dattachetan77.hashnode.dev·May 5, 2024Painter's Partition ProblemProblem Given an array/list of length ‘n’, where the array/list represents the boards and each element of the given array/list represents the length of each board. Some ‘k’ numbers of painters are available to paint these boards. Consider that each u...DiscussLeetcodepainters-partition-problem
Chetan Dattachetan77.hashnode.dev·May 5, 2024410. Split Array Largest SumProblem Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split. A subarray is a contiguous part of the array. (link) Ex...DiscussLeetcodesplit-array-largest-sum