Home
Gaurav's GitHub Page
Cancel

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

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