Coding - Sample Questions For 2027 Batch
Coding - Sample Questions For 2027 Batch
Problem Statement:
You are building a music playlist application, and you want to implement a feature that
allows users to rotate their playlist to change the order of songs. Users can rotate their
playlist by a non-negative number of steps (k steps). When a user rotates the playlist, the
songs in the playlist should be moved to the right by k steps.
If k is greater than the number of songs in the playlist, the rotation should wrap around,
meaning that the songs at the end of the playlist should move to the beginning.
Example:
Input:
N=7
nums = [1,2,3,4,5,6,7]
k=3
Output: [5,6,7,1,2,3,4]
Explanation:
rotate 1 steps to the right: [7,1,2,3,4,5,6]
rotate 2 steps to the right: [6,7,1,2,3,4,5]
rotate 3 steps to the right: [5,6,7,1,2,3,4]
Testcases:
Test case 1:
INPUT:
-10 20 20 2 -40
2
OUTPUT: 2 -40 -10 20 20
Test case 2:
INPUT:
7 8 9 10 7
OUTPUT: 8 9 10 7 7
Problem Statement:
Given string str. The task is to find the maximum occurring character in the string str. If there
are multiple character which have the maximum occurrence, print the char which end at the
last.
Example:
INPUT:
str = everyday
Output: e
Constraint:
1 <=|S|<=10^4
______________________________________________________________________
Test case 1:
INPUT:
test
OUTPUT:
t
Test case 2:
INPUT:
output
OUTPUT:
Problem Statement:
Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order.
Example:
Input:
n=5
arr[] = {0,2,1,2,0}
Output: 0 0 1 2 2
Constraints:
1 <= N <= 10^6
0 <= A[i] <= 2
______________________________________________________________________
TESTCASES:
Testcase 1:
INPUT:
10
1021011012
OUTPUT:
0001111122
Testcase 2:
INPUT:
1
0
OUTPUT:
0
Problem Statement:
Given an integer array ‘nums’, and an integer ‘K’. Print the smallest number present in that
array, which is greater than or equal to K. If no such number exists, print -1.
Example:
Input:
N = 7, Where N is the size of the given array.
K=3
nums = [6,7,3,4,5,1,2]
Output: 3
Explanation:
We print 3 because 3 is the smallest possible number in that array which is greater than or
equal to K =3.
Constraints:
1 <= N,K <= 10^5
0<= nums[i] <= 10^6
Test Cases:
Size of the array
The value of K
____________________________________________________________________________
Testcase 1:
10 18
Output:
29
____________________________________________________________________________
Testcase 2:
73
6734512
Output: