Count inversion

Read more →

Find first and last positions of an element in a sorted array

Read more →

Find a fixed point (value equal to index) in a given array

Read more →

Search in a rotated sorted array

Read more →

Square root of an integer

Read more →

Maximum and minimum of an array using minimum number of comparisons

Read more →

Optimum location of point to minimize total distance

Read more →

Find missing and repeating

Read more →

Find majority element

Read more →

Searching in an array where adjacent differ by at most K

Read more →

Find a pair with a given difference

Read more →

Find four elements that sum to a given value

Read more →

Maximum sum such that no 2 elements are adjacent

Read more →

Count triplet with sum smaller than a given value

Read more →

Merge 2 sorted arrays

Read more →

Print all subarrays with 0 sum

Read more →

Product array puzzle

Read more →

Sort array according to count of set bits

Read more →

Minimum number of swaps required to sort the array

Read more →

Bishu and soldiers

Read more →

Rasta and Kheshtak

Read more →

Kth smallest number again

https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/kth-smallest-number-again-2/ #include <bits/stdc++.h> using namespace std; void solve() { int n, q; cin >> n >> q; vector<pair<int, int>> v(n); for (auto &it : v) cin >> it.first >> it.second; sort(v.begin(), v.end()); int idx = 0; for (int i = 1; i < n; i++) { if (v[idx].second >= v[i].first) { v[idx].second = max(v[idx].second, v[i].second); } else { idx++; v[idx] = v[i]; } } while (q--) { int k; cin >> k; int ans = -1; for (int i = 0; i <= idx; i++) { if (v[i].
Read more →

Find pivot element in a sorted array

Read more →

Kth element of two sorted arrays

Read more →

Aggressive cows

Read more →

Book allocation aka Painter’s Partition

Read more →

Ekospoj

Read more →

Job scheduling algorithm

Read more →

Missing number in AP

Read more →

Smallest number with atleast N trailing zeroes in factorial

Read more →

Roti Prata

Read more →

Doublehelix

Read more →

Subset sums

Read more →

Implement merge-sort in-place

Read more →

Partitioning and sorting arrays with many repeated entries

Read more →