Detail Form
We will send your result on your email id and phone no. please fill detail
You are given two arrays, A and B, of equal size N. The task is to find the minimum value of A[0] * B[0] + A[1] * B[1] +…+ A[N-1] * B[N-1], where shuffling of elements of arrays A and B is allowed.
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Your task is to complete the function minValue() which takes the arrays A[], B[] and its size N as inputs and returns the minimum sum.
Expected Time Complexity: O(N. log(N))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 105
1 ≤ A[] ≤ 106
Geek lost the password of his super locker. He remembers the number of digits N as well as the sum S of all the digits of his password. He know that his password is the largest number of N digits that can be made with given sum S. As he is busy doing his homework, help him retrieving his password.
Example 1:
Example 2:
Constraints:
1 ≤ N ≤ 104
0 ≤ S ≤ 106
Expected Time Complexity : O(N)
Expected Auxilliary Space : O(1)
Given an array arr[ ] of length N consisting cost of N toys and an integer K depicting the amount with you. Your task is to find maximum number of toys you can buy with K amount.
Example 1:
Example 2:
Your Task:
You do not need to read input or print anything. Your task is to complete the function toyCount() which takes the integer N, integer K and the array arr[ ] as input parameters and returns the maximum count of toys you can have.
Expected Time Complexity: O(N * Log(N))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 105
1 ≤ K, arr[i] ≤ 109
Given an array of n elements. Consider array as circular array i.e element after an is a1. The task is to find maximum sum of the difference between consecutive elements with rearrangement of array element allowed i.e after rearrangement of element find |a1 – a2| + |a2 – a3| + …… + |an – 1– an| + |an – a1|.
Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains the number of elements in the array a[] as n and next line contains space separated n elements in the array a[].
Output:
Print an integer which denotes the maximized sum.
Constraints:
1<=T<=100
1<=n<=10000
1<=a[i]<=100000​
Example:
Input:
2
4
4 2 1 8
3
10 12 15
Output:
18
10
You are given an integer input N and you have to find whether it is the sum or the difference of the integer 5. (5+5, 5+5+5, 5-5,5-5-5+5+5…..)
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Your task is to complete the function isValid() which takes an integer N and returns "YES" or "NO".
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
-109<=N<=109