Home Paper Capgemini Coding Questions

Capgemini Coding Questions

by Anup Maurya
2 minutes read

In this article, you’ll learn about Capgemini Coding Questions, which helps you to crack your coding round.

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 :

Sample Test Case
Input :
aabbbbeeeeffggg
Output:
a2b4e4f2g3

2. Problem Statement : Write the code to traverse a matrix in a spiral format.

Sample Test Case
Input :
5 4
1 2 3 4
5 6 7 8
9 10 11 12
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 : You’re given an array of integers, print the number of times each integer has occurred in the array.
Sample Test Case
Input :
10
1 2 3 3 4 1 4 5 1 2
Output :
1 occurs 3 times
2 occurs 2 times
3 occurs 2 times
4 occurs 2 times
5 occurs 1 times

4. Problem Statement : Write a function to solve the following equation a3 + a2b + 2a2b + 2ab2 + ab2 + b3.
Write a program to accept three values in order of a, b and c and get the result of the above equation.

Sample Test Case
Example Input and Output:

Enter the values of a and b:
a = 2
b = 3
Result for a = 2.0 and b = 3.0: 125.0


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.
Sample Test Case
Input
3 4 2 4 0 1 2
Output
20
16
8
Explantion
There are total 3 dealerships
dealerships1 contains 4 cars and 2 bikes
dealerships2 contains 4 cars and 0 bikes
dealerships3 contains 1 cars and 2 bikes
Total number of tyres in dealerships1 is (4 x 4) + (2 x 2) = 20
Total number of tyres in dealerships2 is (4 x 4) + (0 x 2) = 16
Total number of tyres in dealerships3 is (1 x 4) + (2 x 2) = 8

related posts

Leave a Comment

Enable Notifications OK No thanks