Home
Gaurav's GitHub Page
Cancel

Binary Representation (InterviewBit)

PROBLEM DESCRIPTION Given a number N >= 0, find its representation in binary. Example: if N = 6, binary form = 110 InterviewBit SOLUTION public class Solution { public String findDigit...

Verify Prime (InterviewBit)

PROBLEM DESCRIPTION Given a number N, verify if N is prime or not. Return 1 if N is prime, else return 0. InterviewBit SOLUTION If a is a factor of N, then N/a will also be its factor. So, we d...

Find Permutation (InterviewBit)

PROBLEM DESCRIPTION Given a positive integer n and a string s consisting only of letters D or I, you have to find any permutation of first n positive integer that satisfy the given input string. ...

Next Permutation (InterviewBit)

PROBLEM DESCRIPTION Implement the next permutation, which rearranges numbers into the numerically next greater permutation of numbers for a given array A of size N. If such an arrangement is not ...

Rotate Matrix (InterviewBit)

PROBLEM DESCRIPTION You are given a N x N 2D matrix A representing an image. Rotate the image by 90 degrees (clockwise). You need to do this in place. Update the given matrix A. InterviewBit S...

Largest Number (InterviewBit)

PROBLEM DESCRIPTION Given a list of non-negative integers, arrange them such that they form the largest number. Note: The result may be very large, so you need to return a string instead of an int...

Sort array with squares! (InterviewBit)

PROBLEM DESCRIPTION Given a sorted array A containing N integers both positive and negative. You need to create another array containing the squares of all the elements in A and return it in non-...

Pigeonhole Sort

PIGEONHOLE SORT Suitable for sorting integers within a small range when the distribution of values is relatively uniform. The time complexity of Pigeonhole Sort is O(n + Range), ...

Maximum Consecutive Gap (InterviewBit)

PROBLEM DESCRIPTION Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 elements. -You may assume t...

Balance Array (InterviewBit)

PROBLEM DESCRIPTION Given an integer array A of size N. You need to count the number of special elements in the given array. A element is special if removal of that element make the array balance...