Find the smallest value that cannot be represented as sum of any subset of a given array
Leave a comment | Filed under ArraysGiven a sorted array (sorted in non-decreasing order) of positive numbers, find the smallest value that cannot be represented as sum of elements of any subset of given set.
Read More »Rearrange array in alternating positive & negative items with O(1) extra space
Leave a comment | Filed under ArraysGiven an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa maintaining the order of appearance.
Read More »Given two arrays A1[] and A2[], sort A1 in such a way that the relative order among the elements will be same as those are in A2.
Read More »Given an array which is sorted, but after sorting some elements are moved to either of the adjacent positions, i.e., arr[i] may be present at arr[i+1] or arr[i-1]. Write an efficient function to search an element in this array
Read More »Given two sorted arrays such the arrays may have some common elements. Find the sum of the maximum sum path to reach from beginning of any array to end of any of the two arrays.
Read More »Given a number n, find the smallest number that has same set of digits as n and is greater than n. If x is the greatest possible number with its set of digits, then print “not possible”.
Read More »Given a positive integer N, count all possible distinct binary strings of length N such that there are no consecutive 1′s.
Read More »Given a sorted array arr[] and a value X, find the k closest elements to X in arr[].
Read More »Write a code which inputs two numbers m and n and creates a matrix of size m x n (m rows and n columns) in which every elements is either X or 0.
Read More »Given an array of integers and a number x, find the smallest subarray with sum greater than the given value.
Read More »Remove minimum elements from either side such that 2*min becomes more than max
Leave a comment | Filed under ArraysGiven an unsorted array, trim the array such that twice of minimum is greater than maximum in the trimmed array. Elements should be removed either end of the array.
Read More »Divide and Conquer | Set 6 (Search in a Row-wise and Column-wise Sorted 2D Array)
Leave a comment | Filed under ArraysGiven an n x n matrix, where every row and column is sorted in increasing order. Given a key, how to decide whether this key is in the matrix.
Read More »Bucket sort is mainly useful when input is uniformly distributed over a range. For example, consider the following problem.
Read More »Kth smallest element in a row-wise and column-wise sorted 2D array | Set 1
Leave a comment | Filed under ArraysGiven an n x n matrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the given 2D array.
Read More »