All content related to searching Find the Intersection of Two Unsorted Arrays

Given two integer arrays X[] and Y[] of size m and n, respectively, write a program to find the intersection of these two arrays. The intersection of two arrays is a list of distinct numbers which are present in both arrays. The numbers in the intersection can be in any order. Check if two arrays are equal or not

Given two integer arrays X[] and Y[], write a program to check if the arrays are equal or not. Two arrays are equal if they have the same elements in any order. If there are repeated elements, then counts of repeated elements must also be the same for both arrays. Introduction to Hashing

Hashing is an effcient searching technique that maps keys and values into the hash table using a hash function. Explore this blog to learn: how do we perform hash mapping in data structures? How do hash maps work? What are some popular hash functions in programming? The maximum difference between two elements

Given an array A[] of integers, find out the maximum difference between any two elements such that the larger element appears after, the smaller element. In other words, we need to find max(A[j] - A[i]), where A[j] > A[i] and j > i. Find the row with the maximum number of 1s

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s. This is an excellent matrix problem that can be solved in linear time complexity. The best part is — we are using the sorted order property and nested loops to improve the solution over the binary search approach. Find first and last positions of an element in a sorted array

Given an array of integers sorted in ascending order, find the first and last position of a given value. This is a good interview problem to learn problem-solving using binary search. kth smallest element in an array

Given an array and a positive integer k, write a program to find the kth smallest element in the array. One of the famous problems to learn a quick-select approach that helps optimize time complexity to O(n) average. Search in a row-wise sorted 2D matrix

You are given a row-wise sorted 2D matrix and a given integer k, write a program to find whether the integer ‘k’ is present in the matrix or not. The matrix has the following properties: Integers in each row are sorted from left to right and the first integer of each row is greater than the last integer of the previous row. Check for pair in an array with a given sum

Given an array of n integers and a target number, write a program to check whether a pair sum exits in the array or not. In other words, we need to check whether pair of elements in the array sum exactly to the target value. n Repeated element in 2n size array

In an array of size 2n, there are n+1 unique elements, and exactly one of these elements is repeated n times. Return the element repeated n times. Binary Search Algorithm: Fast Searching on Sorted Array!

The binary search is one of the fastest search algorithms, which searches a value in the sorted array in an O(logn) time complexity. Here we search a value using divide and conquer by repeatedly dividing the search interval in half. Problem statement: Given a sorted array X[] of n elements, search a given element key in X[]. If the key exists, then return its index in the sorted array. Otherwise, return -1. Find the minimum and maximum value in an array

Given an array X[] of size n, we need to find the maximum and minimum element present in the array. This coding problem has been asked during facebook and microsoft interview. Find equilibrium index of an array

Write a program to find the equilibrium index of an array. An array's equilibrium index is an index such that sum of elements at lower indexes equal to the sum of elements at higher indexes. This is an excellent coding question to learn — how to optimize space complexity and solve the problem using a single scan.