36 Problems

Searching & Sorting

Master searching & sorting problems with detailed brute force and optimal solutions.

01
Find first and last positions of an element in a sorted array
Click to view brute force and optimal solutions
02
Find a Fixed Point (Value equal to index) in a given array
Click to view brute force and optimal solutions
03
Search in a rotated sorted array
Click to view brute force and optimal solutions
04
Square root of an integer
Click to view brute force and optimal solutions
05
Maximum and minimum of an array using minimum number of comparisons
Click to view brute force and optimal solutions
06
Optimum location of point to minimize total distance
Click to view brute force and optimal solutions
07
Find the repeating and the missing
Click to view brute force and optimal solutions
08
Find majority element
Click to view brute force and optimal solutions
09
Searching in an array where adjacent differ by at most k
Click to view brute force and optimal solutions
10
Find a pair with a given difference
Click to view brute force and optimal solutions
11
Find four elements that sum to a given value
Click to view brute force and optimal solutions
12
Maximum sum such that no 2 elements are adjacent
Click to view brute force and optimal solutions
13
Count triplet with sum smaller than a given value
Click to view brute force and optimal solutions
14
Merge 2 sorted arrays
Click to view brute force and optimal solutions
15
Print all subarrays with 0 sum
Click to view brute force and optimal solutions
16
Product array Puzzle
Click to view brute force and optimal solutions
17
Sort array according to count of set bits
Click to view brute force and optimal solutions
18
Minimum no. of swaps required to sort the array
Click to view brute force and optimal solutions
19
Bishu and Soldiers
Click to view brute force and optimal solutions
20
Rasta and Kheshtak
Click to view brute force and optimal solutions
21
Kth smallest number again
Click to view brute force and optimal solutions
22
Find pivot element in a sorted array
Click to view brute force and optimal solutions
23
K-th Element of Two Sorted Arrays
Click to view brute force and optimal solutions
24
Aggressive cows
Click to view brute force and optimal solutions
25
Book Allocation Problem
Click to view brute force and optimal solutions
26
EKOSPOJ
Click to view brute force and optimal solutions
27
Job Scheduling Algo
Click to view brute force and optimal solutions
28
Missing Number in AP
Click to view brute force and optimal solutions
29
Smallest number with at least n trailing zeroes in factorial
Click to view brute force and optimal solutions
30
Painters Partition Problem
Click to view brute force and optimal solutions
31
ROTI-Prata SPOJ
Click to view brute force and optimal solutions
32
DoubleHelix SPOJ
Click to view brute force and optimal solutions
33
Subset Sums
Click to view brute force and optimal solutions
34
Find the inversion count
Click to view brute force and optimal solutions
35
Implement Merge-sort in-place
Click to view brute force and optimal solutions
36
Partitioning and Sorting Arrays with Many Repeated Entries
Click to view brute force and optimal solutions