Dr.
Rajesh Kumar Panda
Kareer School
1. A chocolate factory is packing
c h o co l ate s i nto t h e p a c ket s . T h e
chocolate packets here represent an
array of N number of integer values.
The task is to find the empty packets(0)
of chocolate and push it to the end of
the conveyor belt(array).
Example 1 :
N=8 and arr = [4,5,0,1,9,0,5,0].
There are 3 empty packets in the given set. These 3 empty packets represented as O should be
pushed towards the end of the array
Input :
8 – Value of N
[4,5,0,1,9,0,5,0] – Element of arr[O] to arr[N-1],While input each element is separated by newline
Output:
45195000
Example 2:
Input:
6 — Value of N.
[6,0,1,8,0,2] – Element of arr[0] to arr[N-1], While input each element is separated by newline
Output:
618200
2. Joseph is learning digital logic subject which
will be for his next semester. He usually tries to
solve unit assignment problems before the
lecture. Today he got one tricky question. The
problem statement is “A positive integer has been
given as an input. Convert decimal value to binary
representation. Toggle all bits of it after the most
significant bit including the most significant bit.
Print the positive integer value after toggling all
bits”.
Constrains-
1<=N<=100
Example 1:
Input :
10 -> Integer
Output :
5 -> result- Integer
Explanation:
Binary representation of 10 is 1010. After toggling the bits(1010), will
get 0101 which represents “5”. Hence output will print “5”.
3. Jack is always excited about sunday. It is
favourite day, when he gets to play all day. And
goes to cycling with his friends.
So every time when the months starts he counts
the number of sundays he will get to enjoy.
Considering the month can start with any day, be
it Sunday, Monday…. Or so on.
Count the number of Sunday jack will get within n
number of days.
Example 1:
Input
mon-> input String denoting the start of the month.
13 -> input integer denoting the number of days from the start of the
month.
Output :
2 -> number of days within 13 days.
Explanation:
The month start with mon(Monday). So the upcoming sunday will arrive in next 6
days. And then next Sunday in next 7 days and so on.
Now total number of days are 13. It means 6 days to first sunday and then
remaining 7 days will end up in another sunday. Total 2 sundays may fall within 13
days.
4. Airport security officials have confiscated
several item of the passengers at the security
check point. All the items have been dumped into
a huge box (array). Each item possesses a certain
amount of risk[0,1,2]. Here, the risk severity of
the items represent an array[] of N number of
integer values. The task here is to sort the items
based on their levels of risk in the array. The risk
values range from 0 to 2.
Example :
Input :
7 -> Value of N
[1,0,2,0,1,0,2]-> Element of arr[0] to arr[N-1], while input each element is separated by new line.
Output :
0 0 0 1 1 2 2 -> Element after sorting based on risk severity
Example 2:
input : 10 -> Value of N
[2,1,0,2,1,0,0,1,2,0] -> Element of arr[0] to arr[N-1], while input each element is separated by a new
line.
Output :
0 0 0 0 1 1 1 2 2 2 ->Elements after sorting based on risk severity.
Explanation:
In the above example, the input is an array of size N consisting of only 0’s, 1’s and 2s. The output is a
sorted array from 0 to 2 based on risk severity.
5. Given an integer array Arr of size N the task is to find the
count of elements whose value is greater than all of its prior
elements.
Note : 1st element of the array should be considered in the
count of the result.
For example,
Arr[]={7,4,8,2,9}
As 7 is the first element, it will consider in the result.
8 and 9 are also the elements that are greater than all of its
previous elements.
Since total of 3 elements is present in the array that meets
the condition.
Hence the output = 3.
Example 1:
Input
5 -> Value of N, represents size of Arr
7-> Value of Arr[0]
4 -> Value of Arr[1]
8-> Value of Arr[2]
2-> Value of Arr[3]
9-> Value of Arr[4]
Output :
3
6. A furnishing company is manufacturing a new
collection of curtains. The curtains are of two
colors aqua(a) and black (b). The curtains color is
represented as a string(str) consisting of a’s and
b’s of length N. Then, they are packed (substring)
into L number of curtains in each box. The box
with the maximum number of ‘aqua’ (a) color
curtains is labeled. The task here is to find the
number of ‘aqua’ color curtains in the labeled box.
Example 1:
Input :
bbbaaababa -> Value of str
3 -> Value of L
Output:
3 -> Maximum number of a’s