1:1 MOCK SESSION WWW.PRIMCECODING.IN 1:1 MOCK SESSION
Capgemini Coding CheatSheet
1. Problem Statement –
Capgemini in its online written test have a coding question, wherein the
students are given a string with multiple characters that are repeated
consecutively. You’re supposed to reduce the size of this string using
mathematical logic given as in the example below :
G
Input :
aabbbbeeeeffggg
IN
Output:
a2b4e4f2g3
D
O
2. Problem Statement –
Write the code to traverse a matrix in a spiral format.
C
Sample Input
Input
E
5 4
IM
1 2 3 4
5 6 7 8
9 10 11 12
PR
13 14 15 16
17 18 19 20
Output
1 2 3 4 8 12 16 20 19 18 17 13 9 5 6 7 11 15 12 14 10
3. Problem Statement –
Capgemini Coding CheatSheet
WWW.PRIMCECODING.IN 1:1 MOCK SESSION
1
, 1:1 MOCK SESSION WWW.PRIMCECODING.IN 1:1 MOCK SESSION
You’re given an array of integers, print the number of times each integer has
occurred in the array.
Example
Input :
10
1233414512
Output :
1 occurs 3 times
G
2 occurs 2 times
3 occurs 2 times
IN
4 occurs 2 times
5 occurs 1 times
D
O
4. Problem Statement –
C
Write a function to solve the following equation a3 + a2b + 2a2b + 2ab2 +
ab2 + b3.
E
Write a program to accept three values in order of a, b and c and get the result
of the above equation.
IM
PR
5. Problem Statement –
A function is there which tells how many dealerships there are and the total
number of cars in each dealership.
Your job is to calculate how many tyres would be there in each dealership.
Input
3
42
40
12
Capgemini Coding CheatSheet
WWW.PRIMCECODING.IN 1:1 MOCK SESSION
2
Capgemini Coding CheatSheet
1. Problem Statement –
Capgemini in its online written test have a coding question, wherein the
students are given a string with multiple characters that are repeated
consecutively. You’re supposed to reduce the size of this string using
mathematical logic given as in the example below :
G
Input :
aabbbbeeeeffggg
IN
Output:
a2b4e4f2g3
D
O
2. Problem Statement –
Write the code to traverse a matrix in a spiral format.
C
Sample Input
Input
E
5 4
IM
1 2 3 4
5 6 7 8
9 10 11 12
PR
13 14 15 16
17 18 19 20
Output
1 2 3 4 8 12 16 20 19 18 17 13 9 5 6 7 11 15 12 14 10
3. Problem Statement –
Capgemini Coding CheatSheet
WWW.PRIMCECODING.IN 1:1 MOCK SESSION
1
, 1:1 MOCK SESSION WWW.PRIMCECODING.IN 1:1 MOCK SESSION
You’re given an array of integers, print the number of times each integer has
occurred in the array.
Example
Input :
10
1233414512
Output :
1 occurs 3 times
G
2 occurs 2 times
3 occurs 2 times
IN
4 occurs 2 times
5 occurs 1 times
D
O
4. Problem Statement –
C
Write a function to solve the following equation a3 + a2b + 2a2b + 2ab2 +
ab2 + b3.
E
Write a program to accept three values in order of a, b and c and get the result
of the above equation.
IM
PR
5. Problem Statement –
A function is there which tells how many dealerships there are and the total
number of cars in each dealership.
Your job is to calculate how many tyres would be there in each dealership.
Input
3
42
40
12
Capgemini Coding CheatSheet
WWW.PRIMCECODING.IN 1:1 MOCK SESSION
2