Problem Statement:
Zlatan is a master of solving tricky questions. His friend gave him some numbers (in the form of an array) and asked him to find the number of subsequences of the array such that its sum is m-1.
Here, m is the sum of the initial given array. Output the number of such subsequences and print it in one line.
Example:
array = [5, 4, 2, 1, 1]
Output: 2
Valid ways are taking the first [5, 4, 2, 1] and then the second [5, 4, 2, 1].
Problem Statement: A professor wanted maximum benefits from a number game. He has information on numbers scattered throughout a game board given in the form of an array. He will surely take three numbers and multiply their values to get the maximum value out of all possible combinations. The array might contain negative numbers as well.
Simply print the maximum value he can get.
Example: array = [-9, 9, 5, -3, 100], n = 5
Output: 4500 Explanation: The three numbers chosen are 9, 5, & 100 which have a multiplication value of 4500.
Problem Statement:
You are given a number n. Your friend added the numbers from 1 till n, TWICE. The sum is S. Now he says that he forgot to add only one number twice (he added it only once).
Determine the number he may have possibly missed out.
Example:
n = 4, S = 14
Output: 3
Explanation: If we add numbers twice from 1 till 4, we get 20. He has a sum of 14, which means 20 - 14 = 6 is missing. But wait, he missed adding a number twice, meaning it's only in the sum once. Expected S = 20, actual S = 14. But the example logic says 20 - 3 - 3 = 14. Wait, the math is expected total minus actual total equals the missing number.
Problem Statement: A king is a person who has:
More kindness than his neighbours.
More kindness than the rest of the people.
Kindness is given by an integer value in an array. Find the position of the king. If there are multiple kings, print all of their positions separated by spaces. (1-based indexing)
Example: kind = [5, 6, 7, 6, 5, 5, 100, 5, 100, 45], n = 11
Output: 8 10 Notice there are two kings, one at the 8th and the other at the 10th position.
Problem Statement: In a class test, many students participated. You have to determine both the number of unique scores and the unique scores as scored by the students.
In the first line, print the unique scores in the order they appear. In the second line, print: "The number of unique scores are X", where X is the number of unique scores.
Example: array = [45, 61, 78, 78, 98, 98]
Output: 45 61 78 98 The number of unique scores are 4
Problem Statement:
Given an array of integers of length n. Find out if there exists a contiguous subarray whose sum is equal to the number K.
If there exists a subarray with a sum equal to K, print the largest and the smallest number in that subarray. If there exists no such subarray, print "-1 -1".
Example:
array = [1, 5, 2, 6, 3, 2], n = 6, k = 7
Output: 5 2
Explanation: The subarray [5, 2] has a sum of 7. The largest value is 5 and the smallest is 2..