Hands-On_Arrays and Functions - Questions
Hands-On_Arrays and Functions - Questions
Hands-on No. : 3a
Date : 14.02.2025
Question
Question Detail Level
No.
1 There is long queue in the billing counter of a supermarket. Tell Easy
the position of the specific customer if the names are the input.
If not found, print -1.
Sample Input: 5, [Smith Tim Eve John Dora], Eve
Sample Output: 3
Sample Input: 5, [Smith Tim Eve John Dora], Mike
Sample Output: -1
2 Given an array of size N-1 such that it only contains distinct Easy
integers in the range of 1 to N. Find the missing element.
Assume that integer range is correctly given.
Sample Input: 5, [1,2,3,5]
Sample Output: 4
Sample Input: 10, [6,1,2,8,3,4,7,10,5]
Sample Output: 9
3 Write a program to find & remove duplicate elements in the array Easy
and reprint.
Sample Input: 1 2 8 3 4 5 5 6 7 8
Sample Output: 1 2 8 3 4 5 6 7
4 Write a program to find pair of elements in the array having sum Easy
of 10. If not found any, return -1.
Sample Input: 1 2 8 3
Sample Output: (2,8)
Sample Input: 1 2 3 4 5
Sample Output: -1
5 Write a Java program to replace each element of the array with Easy
product of all other elements in a given array of integers.
Sample Input: 4,[1 2 3 4]
Sample Output: 24 12 8 6
Test Case 2:
For the first test case, the given number is ‘8’ so using the
encryption technique we follow the steps: ( 8 * 7 / 6 + 5 - 4 * 3
/2-1)=9
Sample Input 2:
1
12
Sample Output 2:
13
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: Because nums[0] + nums[1] == 9, we return [0,
1].
Example 2:
Input: nums = [1, 4, 6, 8, 10], target = 12
Output: [1, 3]
Constraints:
2 <= nums.length <= 10^4
-10^9 <= nums[i] <= 10^9
-10^9 <= target <= 10^9
Examples:
Input : arr[] = {100, 200, 300, 400}, k = 2
Output : 700
Explanation: arr3 + arr4 = 700, which is maximum.
Examples:
Input: x = 51, arr[] = [1, 4, 45, 6, 0, 19]
Output: 3
Explanation: Minimum length subarray is [4, 45, 6]
Input: x = 100, arr[] = [1, 10, 5, 2, 7]
Output: 0
Explanation: No subarray exist
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ arr.size, x ≤ 10^5
0 ≤ arr[] ≤ 10^4
Constraints:
n == code.length
1 <= n <= 100
1 <= code[i] <= 100
-(n - 1) <= k <= n – 1
Example 1:
Input: nums = [1,2,3,4] Output:
[1,3,6,10]
Explanation: Running sum is obtained as follows: [1, 1+2,
1+2+3, 1+2+3+4].
Example 2:
Input: nums = [1,1,1,1,1]
Output: [1,2,3,4,5]
Explanation: Running sum is obtained as follows: [1, 1+1,
1+1+1, 1+1+1+1, 1+1+1+1+1].
Example 3:
Input: nums = [3,1,2,10,1]
Constraints:
1 <= nums.length <= 1000
-10^6 <= nums[i] <= 10^6
i - k <= r <= i + k,
j - k <= c <= j + k, and
(r, c) is a valid position in the matrix.
Example 1:
Output: [[12,21,16],[27,45,33],[24,39,28]]
Example 2:
Output: [[45,45,45],[45,45,45],[45,45,45]]
Constraints:
m == mat.length
n == mat[i].length