Problem Description Given an array of integers A, sort the array into a wave-like array and return it. In other words, arrange the elements into a sequence such that a1 >= a2 <= a3 >= a4...
Set Intersection (InterviewBit)
Problem Description An integer interval [X, Y] (for integers X < Y) is a set of all consecutive integers from X to Y, including X and Y. You are given a 2D array A with dimensions N x 2, where...
Reorder Data in Log Files (InterviewBit)
Problem Description You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words ...
Max Min (InterviewBit)
PROBLEM DESCRIPTION Given an array A of size N. You need to find the sum of Maximum and Minimum element in the given array. interviewbit SOLUTION We can break the array into two sections and se...
Partitions (InterviewBit)
PROBLEM DESCRIPTION You are given a 1D integer array B containing A integers. Count the number of ways to split all the elements of the array into 3 contiguous parts so that the sum of elements i...
Flip (InterviewBit)
PROBLEM DESCRIPTION You are given a binary string A(i.e. with characters 0 and 1) consisting of characters A1, A2, …, AN. In a single operation, you can choose two indices L and R such that 1 ≤ L ...
Maximum Area of Triangle (InterviewBit)
PROBLEM DESCRIPTION Given a character matrix of size N x M in the form of a string array A of size N where A[i] denotes ith row. Each character in the matrix consists any one of the following thr...
Maximum Absolute Difference (InterviewBit)
PROBLEM DESCRIPTION You are given an array of N integers, A1, A2 ,..., AN. Return maximum value of f(i, j) for all 1 ≤ i, j ≤ N. f(i, j) is defined as |A[i] - A[j]| + |i - j|, where |x| denotes ab...
Maximum Sum Triplet (InterviewBit)
PROBLEM DESCRIPTION Given an array A containing N integers. You need to find the maximum sum of triplet ( Ai + Aj + Ak ) such that 0 <= i < j < k < N and Ai < Aj < Ak. If no su...
Minimum Lights to Activate (InterviewBit)
PROBLEM DESCRIPTION There is a corridor in a Jail which is N units long. Given an array A of size N. The ith index of this array is 0 if the light at ith position is faulty otherwise it is 1. All...