Home
Gaurav's GitHub Page
Cancel

Find Duplicate in Array (InterviewBit)

PROBLEM DESCRIPTION Given a read-only array of n + 1 integers between 1 and n, find one number that repeats in linear time using less than O(n) space and traversing the stream sequentially O(1) ti...

Triplets with Sum between given range (InterviewBit)

PROBLEM DESCRIPTION Given an array of real numbers greater than zero in form of strings. Find if there exists a triplet (a,b,c) such that 1 < a+b+c < 2. Return 1 for true or 0 for false. O(...

Spiral Order Matrix II (InterviewBit)

PROBLEM DESCRIPTION Given an integer A, generate a square matrix filled with elements from 1 to A^2 in spiral order and return the generated square matrix. InterviewBit SOLUTION Mark the startR...

Anti Diagonals (InterviewBit)

PROBLEM DESCRIPTION Give a N x N square matrix, return an array of its anti-diagonals. Look at the example for more details. Input: 1 2 3 4 5 6 7 8 9 Output: [ [1], [2, 4], [3, 5, 7], ...

Pascal Triangle (InterviewBit)

PROBLEM DESCRIPTION Given an integer A, equal to numRows, generate the first numRows of Pascal’s triangle. Pascal’s triangle: To generate A[C] in row R, sum up A'[C] and A'[C-1] from the previous...

Kth Row of Pascal's Triangle (InterviewBit)

PROBLEM DESCRIPTION Given an index k, return the kth row of the Pascal’s triangle. Pascal’s triangle: To generate A[C] in row R, sum up A'[C] and A'[C-1] from previous row R - 1. Example: Input...

Segregate 0s and 1s in an array (InterviewBit)

PROBLEM DESCRIPTION You are given an array of 0s and 1s in random order. Segregate 0s on left side and 1s on right side of the array [Basically you have to sort the array]. Traverse array only onc...

Make equal elements Array (InterviewBit)

PROBLEM DESCRIPTION Given an array of all positive integers and an element x. You need to find out whether all array elements can be made equal or not by performing any of the 3 operations: a...

Perfect Peak of Array (InterviewBit)

PROBLEM DESCRIPTION Given an integer array A of size N. You need to check that whether there exist a element which is strictly greater than all the elements on left of it and strictly smaller tha...

Array Sum (InterviewBit)

PROBLEM DESCRIPTION You are given two numbers represented as integer arrays A and B, where each digit is an element. You have to return an array which representing the sum of the two given numbers...