Anda di halaman 1dari 2

1.Given an array,print the next greater element for every element.

The next great er element for an element x is the first greater element on the right side of x in array.Elements for which no greater element exist consider next greater eleme nt as -1.

2.Equilibrium index of an array.Equilibrium index of an array is an index such t hat the sum of elements at lower indexes is equal to the sum of elements at high er indexes.O(n) complexity and O(1) space.

3.Given an unsorted array of numbers.Check if array elements are consecutive.wri te a function that returns true.

4.Search in an row wise and column wise sorted matrix..Given an nxn matrix where every row and column is sorted in increasing order.Given a number x how to deci de whether this x is in the matrix.The designed algorithm should have linear tim e complexity.

5.Check for majority element in sorted array.Write a C function to find if a giv en integer appears more than n/2 times in a sorted array of n integers. 6.Given an array of integers from 1 to n,each number is present once,except for one number.Find the missing number.O(n) complexity

7.Given an array of integers in the range of 1 to n,each number is present twice ,except for 2 numbers.Find those 2 non repeating elements.O(n) complexity

8.Given an array of integers in the range of 1 to n,one number is missing and on e number is repeated twice,find the missing and repeated number.O(n) complexity

9.Given an array of integers in the range of 1 to n,there are n+2 elements,two e lements are repeated,find those repeating elements.O(n) complexity

10.Boolean array puzzle.

11.Find the minimum distance between 2 numbers .O(n) complexity

12.Median of 2 sorted arrays.O(log n) complexity.

13.Find whether an array is subset of another array.

14.Find the minimum length unsorted Subarray,sorting which makes the complete ar ray sorted.

15.Given a number x,count the number of occurrences of x in a sorted array.

16.Segregate even and odd numbers in an array.O(n) complexity. 17.Segregate 0's and 1's in an array.O(n) complexity. 18.Find the smallest and second smallest in minimum number of comparisons.O(n) c omplexity 19.Find the kth smallest element in an array.O(n) complexity. 20.Given a sorted array,find the element whose value is equal to the index i.e a rr[x] = x,solve it on O(log n) time 21.Maximum sum of contiguous elements.O(n) complexity

22.Design a stack which supports push, pop, min and max operations in O(1) time. u can use extra space

23.To find the k largest elements in an array(Use Max/Min-heap or order statisti cs algo)

24.There is a sorted array and sum is given to you and u have to find those 2 nu mbers whose sum is equal to that sum in O(n) complexity.