Coding Part 1
Coding Part 1
QUESTIONS
QUESTION - 1
Problem Statement – An automobile company manufactures both a two wheeler (TW) and
a four wheeler (FW). A company manager wants to make the production of both types of
vehicle according to the given data below:
1st data, Total number of vehicle (two-wheeler + four-wheeler)=v 2nd data, Total number
of wheels = W The task is to find how many two-wheelers as well as four-wheelers need
to manufacture as per the given data
Example : Input : 200 -> Value of V 540 ->
Value of W Output : TW =130 FW=70
QUESTION -1
Explanation:
130+70 = 200 vehicles
(70*4)+(130*2)= 540 wheels
Constraints :
2<=W
W%2=0
V<W
Print “INVALID INPUT” , if inputs did not meet the constraints
QUESTION - 1
• The input format for testing The candidate has to write the code to accept two positive
numbers separated by a new line. First Input line – Accept value of V. Second Input line-
Accept value for W. The output format for testing Written program code should
generate two outputs, each separated by a single space character (see the example)
Additional messages in the output will result in the failure of test case
QUESTION - 2
Problem Statement – Given a string S(input consisting) of ‘*’ and ‘#’. The length of the
string is variable. The task is to find the minimum number of ‘*’ or ‘#’ to make it a valid
string. The string is considered valid if the number of ‘*’ and ‘#’ are equal. The ‘*’ and ‘#’
can be at any position in the string. Note : The output will be a positive or negative integer
based on number of ‘*’ and ‘#’ in the input string. • (*>#): positive integer • (#>*): negative
integer • (#=*): 0
Example 1: Input 1: • ###*** -> Value of S Output : • 0 → number of * and # are equal
QUESTION - 3
3) 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.
QUESTION - 3
• Example 1: • Example 2:
Input 5 -> Value of N, represents size of Arr
• 5 -> Value of N, represents size of Arr • 3 -> Value of Arr[0]
• 7-> Value of Arr[0] • 4 -> Value of Arr[1]
• 4 -> Value of Arr[1] • 5 -> Value of Arr[2]
• 8-> Value of Arr[2] • 8 -> Value of Arr[3]
• 2-> Value of Arr[3] • 9 -> Value of Arr[4]
• 9-> Value of Arr[4] • Output : 5
• Output : 3 • Constraints •1<=N<=20 1<=Arr[i]<=10000
QUESTION - 4
• A parking lot in a mall has RxC number of parking spaces. Each parking space will either
be empty(0) or full(1). The status (0/1) of a parking space is represented as the element
of the matrix. The task is to find index of the prpeinzta row(R) in the parking lot that has
the most of the parking spaces full(1).
Note : RxC- Size of the matrix Elements of the matrix M should be only 0 or 1.
Example 1: Input : 3 -> Value of R(row) 3 -> value of C(column) [0 1 0 1 1 0 1 1 1] ->
Elements of the array M[R][C] where each element is separated by new line.
Output : 3 -> Row 3 has maximum number of 1’s
QUESTION - 4
Example 2:
input : 4 -> Value of R(row)
3 -> Value of C(column)
[0 1 0 1 1 0 1 0 1 1 1 1] -> Elements of the array M[R][C]
Output : 4 -> Row 4 has maximum number of 1’s
QUESTION - 5
• A party has been organised on cruise. The party is organised for a limited time(T). The number
of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of
the array. The task is to find the maximum number of guests present on the cruise at any given
instance within T hours.
Example 1: Input : • 5 -> Value of T •
[7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line
[1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line.
QUESTION - 5
• Output : Hour 3:
• 8 -> Maximum number of guests on cruise at an instance. Entry: 5 Exit: 1
• Explanation: No. of guests on ship : 4+5-1=8
• 1st hour: Hour 4:
• Entry : 7 Exit: 1 Entry : 1 Exit : 3
• No. of guests on ship : 6 No. of guests on ship : 8+1-3=6
• 2nd hour : Hour 5:
• Entry : 0 Exit : 2 Entry : 3 Exit: 4
• No. of guests on ship : 6-2=4 No. of guests on ship: 6+3-4=5
Hence, the maximum number of guests within 5 hours is 8
QUESTION - 5
• Hence, the maximum number of guests within 5 hours is 6. The input format for testing
The candidate has to write the code to accept 3 input. First input- Accept value for
number of T(Positive integer number) Second input- Accept T number of values, where
each value is separated by a new line. Third input- Accept T number of values, where
each value is separated by a new line. The output format for testing The output should
be a positive integer number or a message as given in the problem statement(Check the
output in Example 1and Example 2)
QUESTION - 5
• Constraints:
• • 1<=T<=25
• • 0<= E[i] <=500
• • 0<= L[i] <=500