+91-9944878589
www.qriocity.in
Company Specific Problems
Service Based
Tata Consultancy Services
Problem 1
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)=
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
Problem 2
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.
1
+91-9944878589
www.qriocity.in
Note : The output will be a positive or negative integer based on number of ‘*’
and ‘#’ in the input string
(*>#): positive intege
(#>*): negative intege
(#=*): 0
Example 1:
Input 1
###*** -> Value of S
Output
0 → number of * and # are equal
Problem 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.
Problem 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).
2
+91-9944878589
www.qriocity.in
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
Problem 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
[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.
Output :
8 -> Maximum number of guests on cruise at an instance.
3
+91-9944878589
www.qriocity.in
Cognizant
Sum of Digits of a numbe
Palindrome Strin
Reverse a Strin
Reverse a Numbe
Check Palindrome Number
Infosys
Program to sort a string of character
Program to count the number of unique characters in a given strin
Program to multiply two matrices and print the result through
another matri
Given a string find the next permutation of the given strin
Write a program to find the area of the incircle of a right angles
triangle
Wipro
How to swap two numbers without using a temporary variable
Different Methods to Reverse a String in C+
Print alternate elements of an array
Value equal to index valu
At least two greater elements
4
+91-9944878589
www.qriocity.in
Capgemini
Problem 1
Write a function that will accept a string whose length is “len”, the string has
some “#” keywords in it. Now move all the hashes ‘#’ to the front of the string
and return the whole string back and last print it.
Sample Test Case:
Input: The#Learn#Programo
Output: ###TheLearnProgramo
Problem 2
The string contains multiple characters that are repeated consecutively. Now,
write a program that will reduce the size of the string using the given
mathematical logic.
Sample Test Case:
Input: abbcccddddeeeee
Output: a1b2c3d4e5
Problem 3
You will be given an array and you’ve to print the number of times that elements
occur in the given array.
5
+91-9944878589
www.qriocity.in
Sample Test Case:
Input:
10
1 3 4 2 1 2 2 1 4 3
Output:
1 occurs 3 times
2 occurs 3 times
3 occurs 2 times
4 occurs 2 times
Problem 4
Write a program that can traverse a matrix in a spiral format.
Sample Test Case:
Input:
3 3
1 2 3
4 5 6
7 8 9
Output: 1 2 3 6 9 8 7 4 5
Problem 5
There are multiple dealerships for cars and bikes. Now, write a program that will
calculate how many types are in each and every dealership.
Sample Test Case:
Input:
2 4
5 0
1 2
Output: 16 20 8
6
+91-9944878589
www.qriocity.in
Product based
ZOHO
Problem 1
Write a program to give the following output for the given input
Eg 1: Input: a1b10
Output: abbbbbbbbbb
Eg: 2: Input: b3c6d15
Output: bbbccccccddddddddddddddd
The number varies from 1 to 99.
Problem 2
Write a program to sort the elements in odd positions in descending order and
elements in ascending order
Eg 1: Input: 13,2 4,15,12,10,5
Output: 13,2,12,10,5,15,4
Eg 2: Input: 1,2,3,4,5,6,7,8,9
Output: 9,2,7,4,5,6,3,8,1
Problem 3
Find if a String2 is substring of String1. If it is, return the index of the first
occurrence. else return -1.
Eg 1:
Input:
String 1: test123string
String 2: 123
Output: 4
7
+91-9944878589
www.qriocity.in
Problem 4
Given two sorted arrays, merge them such that the elements are not repeated
Eg 1:
Input:
Array 1: 2,4,5,6,7,9,10,13
Array 2: 2,3,4,5,6,7,8,9,11,15
Output:
Merged array: 2,3,4,5,6,7,8,9,10,11,13,15
Problem 5
Using Recursion reverse the string such as
Eg 1: Input: one two three
Output: three two one
Eg 2: Input: I love india
Output: india love I
Freshworks
Subarray with given su
Count the triplet
Kadane’s Algorith
Missing number in arra
Merge two sorted arrays
8
+91-9944878589
www.qriocity.in
PayPal
K’th smallest elemen
Trapping Rain Wate
Pythagorean Triple
Chocolate Distribution Proble
Stock buy and sell
Amazon
Sort an array of 0s, 1s and 2
Equilibrium poin
Leaders in an arra
Minimum Platform
Reverse array in groups
Growfin
Element with left side smaller and right side greate
Convert array into Zig-Zag fashio
Last Index of
Spirally traversing a matri
Largest Number formed from an Array