Given an array of positive integers we have to find number of pair of elements whose difference is smaller than average difference. Average difference is defined as (max(A)-min(A))/(n-1), where A is the array and Read more →
Arrays
106 postsGiven a matrix mat[][] of size M x N integers where M is the number of rows and N is the number of columns and a number K. The task is to Read more →
Given heights of n rectangles and two positive integers x and y. You start moving from the rectangle at 0th index. In one move you can perform one of the following operations: Read more →
Sort a list in JAVA and then return the index of elements in sorted order. Examples: Input : [2, 3, 1, 4, 5] Output : [2, 0, 1, 3, 4] After sorting Read more →
Given an array A of size N. A boolean array B consisting of N-1 elements indicates that if B[i] is 1 then A[i] can be swapped with A[i+1]. Find if A can Read more →
Given an array of N integers, where each value represents the volume of the cloud. The task is to choose the two highest volume clouds from an array and smash them together. Read more →
Given an array arr[] of 2N integers, where N is any positive integer. The task is to divide the array into N pairs such that the pair sum minimizes the maximum sum Read more →
Given a list of n integers and consider another list which has n-1 “<” or “>” operators. Your task is to form a valid sequence by rearranging the initial list such that Read more →
Find maximum sum of array A, where k swap can be possible between array A and B. Size of array A and B is N. Examples: Input : N = 5 k Read more →
Given an unsorted array of integers which may contain repeated elements, sort the elements in ascending order of sum of its occurrence and print only distinct elements. If there exist more than Read more →