Home
Gaurav's GitHub Page
Cancel

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

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