Professional Documents
Culture Documents
W8-D3 Tests
W8-D3 Tests
Given an even number N (greater than 2), return two prime numbers whose sum
will be equal to given number. There are several combinations possible. Print only
the pair whose minimum value is the smallest among all the minimum values of
pairs and print the minimum element first.
Example 1:
Input: N = 74
Output: 3 71
Explaination: There are several possibilities
like 37 37. But the minimum value of this pair
is 3 which is smallest among all possible
minimum values of all the pairs.
Example 2:
Input: 4
Output: 2 2
Explaination: This is the only possible
prtitioning of 4.
2. Rotate by 90 degree
Example 1:
Input:
N = 3
matrix[][] = [[1 2 3],
[4 5 6],
[7 8 9]]
Output:
3 6 9
2 5 8
1 4 7
Given a string consisting of lowercase english alphabets, reverse only the vowels
present in it and print the resulting string.
Example 1:
Input:
S = "geeksforgeeks"
Output: geeksforgeeks
Explanation: The vowels are: e, e, o, e, e
Reverse of these is also e, e, o, e, e.
Example 2:
Input:
S = "practice"
Output: prectica
Explanation: The vowels are a, i, e
Reverse of these is e, i, a.
Example 3:
Input:
S = "bcdfg"
Output: bcdfg
Explanation: There are no vowels in S.
4. Remaining String
Given a string S without spaces, a character ch, and an integer count, the task is to
find the string after the specified character has occurred count number of times.
Example 1:
Example 2:
5. Total count
BasicAccuracy: 48.74%Submissions: 25K+Points: 1
Given an array Arr of N positive integers and a number K where K is used
as a threshold value to divide each element of the array into sum of
different numbers. Find the sum of count of the numbers in which array
elements are divided.
Example 1:
Input:
N = 4, K = 3
Arr[] = {5, 8, 10, 13}
Output: 14
Explanation: Each number can be expressed as sum
of different numbers less than or equal to K as
5 (3 + 2), 8 (3 + 3 + 2), 10 (3 + 3 + 3 + 1),
13 (3 + 3 + 3 + 3 + 1). So, the sum of count
of each element is (2+3+4+5)=14.
Example 2:
Input:
N = 5, K = 4
Arr[] = {10, 2, 3, 4, 7}
Output: 8
Explanation: Each number can be expressed as sum of
different numbers less than or equal to K as
10 (4 + 4 + 2), 2 (2), 3 (3), 4 (4) and 7 (4 + 3).
So, the sum of count of each element is
(3 + 1 + 1 + 1 + 2) = 8.