1. Find the missing number in Arithmetic Progression [ Check ]
2. Given an array A[] and a number x, check for pair in A[] with sum as x [ Check Here ]
3. Majority Element
Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). [ Check Here ]
4. Find the Number Occurring Odd Number of Times [ Check Here ]
Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space.
5. Largest Sum Contiguous Subarray [ Ans ]
Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
6. Search an element in a sorted and rotated array [ Ans ]
7. Merge an array of size n into another array of size m+n [ Ans ]
8. Write a program to reverse an array or string [ Ans ]
9. Program for array rotation
10. Leaders in an array [ Ans ]
Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2.
11. Find the smallest and second smallest element in an array [ Ans ]
12. Segregate Even and Odd numbers [ Ans ]
13. Check for Majority Element in a sorted array
14. Maximum and minimum of an array using minimum number of comparisons [ Ans ]
15. Segregate 0s and 1s in an array [ Ans ]
16. Sort an array of 0s, 1s and 2s [ Ans ]
17. Find the two repeating elements in a given array [ Ans ]
18. Find duplicates in O(n) time and O(1) extra space [ Ans ]
19. Find the element that appears once [ Ans ]
20. Count 1’s in a sorted binary array [ Ans ]
21. Given a sorted array and a number x, find the pair in array whose sum is closest to x
[ Ans ]
22. Print All Distinct Elements of a given integer array [ Ans ] ( use HashSet )
23. Find the minimum element in a sorted and rotated array [ Ans ]
24. Floor and Ceiling in a sorted array [ Ans ]
25. Union and Intersection of two sorted arrays
26. Count the number of occurrences in a sorted array
27. Maximum of all subarrays of size k (Added a O(n) method) *****
28. Find whether an array is subset of another array
29. Find the element before which all the elements are smaller than it, and after which all are greater
30. Find the odd appearing element in O(Log n) time [ Ans ]
No comments:
Post a Comment