Given an array of integers, find the nearest smaller number for every element such that the smaller element is on left side.

Examples:

Input: arr[] = {1, 6, 4, 10, 2, 5} Output: {-1, 1,… Read More

Interview Questions asked in Google, Microsoft, Amazon

by Dhaval Dave

Given an array of integers, find the nearest smaller number for every element such that the smaller element is on left side.

Examples:

Input: arr[] = {1, 6, 4, 10, 2, 5} Output: {-1, 1,… Read More

by Dhaval Dave

(Below is the table of price rule) Come up with data structure you can store these price rules

by Dhaval Dave

With First look you think practical way of solving this question, and that is randomly taking a bolt and finding (by Looking at all nuts) perfect fit nut for it.

but does such logic to … Read More

by Dhaval Dave

**Power Set **Power set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then P(s) =

by Dhaval Dave

Stock Price on each day is given in an array.

Example : [ 10, 12, 7, 5, 9, 15, 13, 18 ]
Find the max profit that you can make by buying and selling in … Read More

by Dhaval Dave

Given an array of integers, find out the difference between any two elements such that larger element appears after the smaller number.

Examples: … Read More

by Dhaval Dave

Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once.

Expected time complexity is O(n) and O(1) extra space.

Examples:

Input: arr[] =

… Read More Expected time complexity is O(n) and O(1) extra space.

Examples:

Input: arr[] =

by Dhaval Dave

We have array a[ ]= {1, 2, 3, 4, 5, 6, 7, 8, 4, 10};

And we need to find a number which is duplicate in O(n) and Space complexity O(1)

**Method 1 ) Sorting**

by Dhaval Dave

The longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order.For example, length of LIS

… Read More by Dhaval Dave

Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.

Input :

arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6}

k = 3

… Read More Input :

arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6}

k = 3