Level: Easy Topics: Array, Hash Table, Two Pointers, Binary Search, Sorting Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example...
Searching is the process of finding a particular element in a collection of items, such as an array, list, or database. The goal of searching is to locate the position of the desired item in the collection, if it exists, or to determine that the item...
Problem Statement You're given a function isBadVersion(version) that returns whether a version is bad. You have a series of versions numbered from 1 to n, and your task is to find the first bad version. Once a version is bad, all the following versio...
Problem Statement You are playing a game where a number is picked from 1 to n, and you have to guess the picked number. For each guess you make, you are given feedback: If your guess is higher than the picked number, the API returns -1. If your gue...
Problem Description: Given a list of numbers obtained by rotating a sorted list an unknown number of times, write a function to determine the minimum number of times the original sorted list was rotated to obtain the given list. Your function should ...
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...
Binary 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...
Problem 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...
Problem 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...
Problem 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...