Home
Gaurav's GitHub Page
Cancel

Move Zeroes (InterviewBit)

PROBLEM DESCRIPTION Given an integer array A, move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a cop...

N/3 Repeat Number (InterviewBit)

PROBLEM DESCRIPTION You’re given a read-only array of N integers. Find out if any integer occurs more than N/3 times in the array in linear time and constant additional space. If so, return the i...

Repeat and Missing Number Array (InterviewBit)

PROBLEM DESCRIPTION You are given a read only array of n integers from 1 to n. Each integer appears exactly once except A which appears twice and B which is missing. Return A and B. Note: Your ...

First Missing Integer (InterviewBit)

PROBLEM DESCRIPTION Given an unsorted integer array, find the first missing positive integer. Your algorithm should run in O(n) time and use constant space. InterviewBit SOLUTION Let’s understa...

Maximum Sum Square SubMatrix (InterviewBit)

PROBLEM DESCRIPTION Given a 2D integer matrix A of size N x N find a B x B submatrix where B <= N and B >= 1, such that sum of all the elements in submatrix is maximum. InterviewBit SOLUTI...

Maximum Unsorted Subarray (InterviewBit)

Problem Description Given an array A of non-negative integers of size N. Find the minimum sub-array Al, Al+1 ,..., Ar such that if we sort(in ascending order) that sub-array, then the whole array ...

Max Distance (InterviewBit)

Problem Description Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. InterviewBit Solution Intuition: For any element, if we know the lar...

Hotel Bookings Possible (InterviewBit)

Problem Description A hotel manager has to process N advance bookings of rooms for the next season. His hotel has C rooms. Bookings contain an arrival date and a departure date. He wants to find o...

Wave Array (InterviewBit)

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...