Capgemini Menu9>
PREPINSTA PRIME
Capgemini Exceller Coding Questions 2025
Capgemini Exceller Coding Questions and Answers 2025
Capgemini Exceller Coding Questions round has been very important to the Capgemini Exceller selection process for 2025 graduates. This round is conducted on the Superset platform and includes 2 coding problems, which you must solve within 45 minutes. The purpose of this section is to test your programming skills, logical thinking, and overall problem-solving ability.
Below, we have provided sample Capgemini Exceller Coding Questions from previous years to help you understand the difficulty level and practice effectively.
Details for Capgemini Exceller Coding Round
| Coding Round | Important Information |
|---|---|
| Total no. of question | 2 |
| Allotted Time | 45 mins |
| Section Property | Mandatory |
| Difficulty | High |
Capgemini Exceller has started asking Coding Questions, but it is asked in a special hiring where the package being offered is more than the normal hiring.
- Package offered for this post is 7.5LPA, and since the package being offered is comparatively higher than the normal hiring process, the selection process and test difficulties level are also higher than normal.
- Coding Round is the second major stage of the Capgemini Exceller recruitment process and carries a high weightage in the overall selection. This round tests your problem solving ability, coding logic, and understanding of basic data structures.
Important Details:
- Total Questions: 2
- Difficulty Level: Easy to Medium
- Time Allotted: 45 minutes
- Languages Allowed: C, C++, Java
- Python is NOT allowed in the Exceller drive.
Capgemini Exceller Recruitment Process 2025
- Online Assessment
- Technical MCQs + Pseudocode
- English MCQs
- Game Based Cognitive Test
- Behavioral / PowerSkills Assessment
- Coding Round
- 2 Coding Questions
- Languages allowed: Java, C, C++
- Technical Interview
- HR Interview
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Practice Questions for Capgemini Exceller Coding Round
Question 1:
Problem Statement –
You have write a function that accepts, a string which length is “len”, the string has some “#”, in it you have to move all the hashes to the front of the string and return the whole string back and print it.
char* moveHash(char str[],int n);
Example :
Sample Test Case
Input:
Move#Hash#to#Front
Output:
###MoveHashtoFront
#include<string.h>
#include<stdio.h>
void moveHash(char str[])
{
char str1[100] = {0}, str2[100] = {0};
int i, j = 0, k = 0;
for (i = 0; str[i]; i++)
{
if (str[i] == '#')
str1[j++] = str[i];
else
str2[k++] = str[i];
}
strcat(str1, str2);
printf("%s", str1);
}
int main()
{
char a[100];
scanf("%[^\n]s", a);
moveHash(a);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
char *moveHash(char str[],int n)
{
char str1[100],str2[100];
int i,j=0,k=0;
for(i=0;str[i];i++)
{
if(str[i]=='#')
str1[j++]=str[i];
else
str2[k++]=str[i];
}
strcat(str1,str2);
cout<<str1;
}
int main()
{
char a[100], len;
cin>>a;
len = strlen(a);
moveHash(a, len);
return 0;
}import java.util.*;
public class MoveHash
{
public static void moveHash(String str ,int n)
{
String str1= new String("");
String str2= new String("");
int i=0;
for(i=0;i<n;i++)
{
if(str.charAt(i)=='#')
str1=str1 + str.charAt(i);
else
str2 = str2 + str.charAt(i);
}
String result = str1.concat(str2);
System.out.println(result);
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
int len= a.length();
moveHash(a, len);
}
}Question 2
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 :
Input :
aabbbbeeeeffggg
Output:
a2b4e4f2g3
Input :
abbccccc
Output:
ab2c5
#include<stdio.h>
int main()
{
char str[100];
scanf("%[^\n]s",str);
int i, j, k=0, count = 0;
char str1[100];
for(i=0; str[i]!='\0'; i++)
{
count = 0;
for(j=0; j<=i; j++)
{
if(str[i]==str[j])
{
count++;
}
}
if(count==1)
{
str1[k] = str[i];
k++;
}
}
for(i=0; i<k; i++)
{
count = 0;
for(j=0; str[j]!='\0'; j++)
{
if(str1[i]==str[j])
{
count++;
}
}
if(count==1)
{
printf("%c",str1[i]);
}
else
{
printf("%c%d",str1[i],count);
}
}
return 0;
}#include<iostream>
#include<string>
int main()
{
string str;
getline(cin, str);
string uni = "";
int i, j, count;
for(i = 0; i < str.length(); i++)
{
count = 0;
for(j = 0; j <= i; j++)
{
if(str[i] == str[j])
count++;
}
if(count == 1)
uni += str[i];
}
for(i = 0; i < uni.length(); i++)
{
count = 0;
for(j = 0; j < str.length(); j++)
{
if(uni[i] == str[j])
count++;
}
if(count == 1)
cout << uni[i];
else
cout << uni[i] << count;
}
return 0;
}
import java.util.*;
public class CharacterCount
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int i, j, k = 0, count = 0;
String uni = new String("");
for(i=0; i<str.length(); i++)
{
count = 0;
for(j=0; j<=i; j++)
{
if(str.charAt(i)==str.charAt(j))
{
count++;
}
}
if(count==1)
{
uni = uni + str.charAt(i);
}
}
for(i=0; i<uni.length(); i++)
{
count = 0;
for(j=0; j<str.length(); j++)
{
if(uni.charAt(i)==str.charAt(j))
{
count++;
}
}
if(count==1)
{
System.out.printf("%c",uni.charAt(i));
}
else
{
System.out.printf("%c%d",uni.charAt(i),count);
}
}
}
}Question 3
Problem Statement –
Write the code to traverse a matrix in a spiral format.
Sample Input
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
#include<stdio.h>
int main()
{
int a[5][4] = {
{1,2,3,4},
{5,6,7,8},
{9,10,11,12},
{13,14,15,16},
{17,18,19,20}
};
int rs = 0, re = 5, cs = 0, ce = 4;
int i, j;
for(i = 0; i < 5; i++)
{
for(j = 0; j < 4; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
printf("\nSpiral Order:\n");
while(rs < re && cs < ce)
{
for(i = cs; i < ce; i++)
printf("%d\t", a[rs][i]);
rs++;
for(i = rs; i < re; i++)
printf("%d\t", a[i][ce - 1]);
ce--;
if(rs < re) { for(i = ce - 1; i >= cs; i--)
printf("%d\t", a[re - 1][i]);
re--;
}
if(cs < ce) { for(i = re - 1; i >= rs; i--)
printf("%d\t", a[i][cs]);
cs++;
}
}
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
int a[5][4] = {
{1,2,3,4},
{5,6,7,8},
{9,10,11,12},
{13,14,15,16},
{17,18,19,20}
};
int rs = 0, re = 5, cs = 0, ce = 4;
cout << "Matrix:\n";
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 4; j++)
cout << a[i][j] << "\t";
cout << endl;
}
cout << "\nSpiral Order:\n";
while(rs < re && cs < ce)
{
for(int i = cs; i < ce; i++)
cout << a[rs][i] << "\t";
rs++;
for(int i = rs; i < re; i++)
cout << a[i][ce - 1] << "\t";
ce--;
if(rs < re) { for(int i = ce - 1; i >= cs; i--)
cout << a[re - 1][i] << "\t";
re--;
}
if(cs < ce) { for(int i = re - 1; i >= rs; i--)
cout << a[i][cs] << "\t";
cs++;
}
}
return 0;
}
import java.util.*;
public class Solution
{
public static List<Integer> solve(int [][]matrix,int row,int col)
{
List<Integer> res=new ArrayList<Integer>();
boolean[][] temp=new boolean[row][col];
int []arr1={0,1,0,-1};
int []arr2={1,0,-1,0};
int di=0,r=0,c=0;
for(int i=0;i<row*col;i++)
{
res.add(matrix[r][c]);
temp[r][c]=true;
int count1=r+arr1[di];
int count2=c+arr2[di];
if(count1>=0 && row>count1 && count2>=0 && col>count2 && !temp[count1][count2]){
r=count1;
c=count2;
}
else
{
di=(di+1)%4;
r+=arr1[di];
c+=arr2[di];
}
}
return res;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
int n=sc.nextInt();
int matrix[][]=new int[m][n];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
matrix[i][j]=sc.nextInt();
}
System.out.println(solve(matrix,m,n));
}
}
Question 4
Problem Statement –
You’re given an array of integers, print the number of times each integer has occurred in the array.
Example
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
Run
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int arr[n];
int count;
int k=0;
for(int i=0; i<n; i++)
{
scanf("%d",&arr[i]); //input of arrray
}
int newarr[n];
//step 1
for(int i=0; i<n; i++)
{
count = 0;
for(int j=0; j<=i; j++)
{
if(arr[i]==arr[j])
{
count++;
}
}
if(count==1)
{
newarr[k] = arr[i];
k++;
}
}
//step 2
for(int i=0; i<k; i++)
{
count = 0;
for(int j=0; j<n; j++)
{
if(newarr[i]==arr[j])
{
count++;
}
}
printf("%d occurs %d times\n",newarr[i],count);
}
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin >> n;
int arr[n];
for(int i = 0; i < n; i++)
cin >> arr[i];
int newarr[n];
int k = 0, count = 0;
// Step 1: Collect unique elements in order
for(int i = 0; i < n; i++)
{
count = 0;
for(int j = 0; j <= i; j++)
{
if(arr[i] == arr[j])
count++;
}
if(count == 1)
{
newarr[k] = arr[i];
k++;
}
}
// Step 2: Count total occurrences of each unique element
for(int i = 0; i < k; i++)
{
count = 0;
for(int j = 0; j < n; j++)
{
if(newarr[i] == arr[j])
count++;
}
cout << newarr[i] << " occurs " << count << " times" << endl;
}
return 0;
}
import java.util.Scanner;
public class ArrayFrequency
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int array[] = new int[n]; // taking value of integer
int count = 0;
int k = 0;
for(int i=0; i<n; i++)
{
array[i] = sc.nextInt(); //elements of array
}
//step - 1
int newarray[] = new int[n];
for(int i=0; i<n; i++)
{
count = 0;
for(int j=0; j<=i; j++)
{
if(array[i]==array[j])
{
count++;
}
}
if(count == 1)
{
newarray[k] = array[i];
k++;
}
}
//step 2;
for(int i=0; i<k; i++)
{
count = 0;
for(int j=0; j<n; j++)
{
if(newarray[i] == array[j])
{
count++;
}
}
System.out.printf("%d occurs %d times\n",newarray[i],count);
}
}
}Question 5
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.
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
int sum;
sum=(a+b)*(a+b)*(a+b);
printf("%d",sum);
}#include<iostream.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int sum;
sum=(a+b)*(a+b)*(a+b);
cout<<sum;
}Run
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt(); // even though 'c' is unused, kept to match original code
int sum = (a + b) * (a + b) * (a + b);
System.out.println(sum);
}
}
Question 6
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
4 2
4 0
1 2
Output
20
16
8
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
Run
#include<stdio.h>
int main()
{
int t,cars,bikes;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%d%d",&cars,&bikes);
printf("%d\n",cars*4+bikes*2);
}
}Run
#include<iostream.h>
using namespace std;
int main()
{
int t,cars,bikes;
cin>>t;
for(int i=0;i<t;i++)
{
cin>>cars>>bikes;
cout<<cars*4+bikes*2;
cout<<"\n";
}
}Run
import java.util.*;
public class Solution
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int dealership=sc.nextInt();
while(dealership-->0)
{
int cars=sc.nextInt();
int bikes=sc.nextInt();
System.out.println(cars*4+bikes*2);
}
}
}Prepare more coding questions....
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment

Q-2
import java.io.*;
public class ReduceLengthString {
public static String Solution(String str){
String s = “”;
char a[] = new char[200];
int count = 0;
for(int i=0;i<str.length();i++){
count = 0;
for(int j=0;j 1){
s = s+str.charAt(i);
s = s+(count+””);
}
a[str.charAt(i)]++;
}
}
return s;
}
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println();
String str = br.readLine();
System.out.println(Solution(str));
}
}
Question 4
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int [] arr = new int [10];
int count, prev = 0;
for (int i = 0; i < 10; i ++) {
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
for (int i = 0; i < 10; i += prev) {
count = 1;
for (int j = i + 1; j < 10; j ++) {
if (arr[i] == arr[j]) {
count ++;
}
}
prev = count;
System.out.printf("%d occurs %d times", arr[i], count);
System.out.println();
}
}
}
Question 2
public class Main
{
public static void main(String[] args) {
String str = “aabbbbeeeeffggg”;
int count, prev = 0;
for (int i = 0; i < str.length(); i += prev) {
count = 1;
for (int j = i + 1; j < str.length(); j ++) {
if (str.charAt(i) == str.charAt(j)) {
count ++;
}
}
prev = count;
System.out.print(str.charAt(i));
System.out.print(count);
}
}
}
Question 1
public class Main
{
public static void main(String[] args) {
String str1 = new String(“M#ve#Hash#to#Fr#nt”);
char [] arr = new char[str1.length()];
for (int i = 0; i < str1.length(); i ++) {
if (str1.charAt(i) == '#') {
arr[i] = str1.charAt(i);
}
}
String str2 = String.valueOf(arr);
str1 = str1.replace("#", "");
System.out.println(str2.concat(str1));
}
}
Hey, Join our TA Support Group on Discord, where we will help you out with all your queries:
Discord
Question 4
import java.util.*;
public class Main {
public static void main(String[] args) {
int i, j, count = 0;
ArrayList arr = new ArrayList();
Scanner sc = new Scanner(System.in);
for (i = 0; i < 5; i++) {
arr.add(sc.nextInt());
}
for (i = 0; i < arr.size(); i++) {
count=1;
for (j = i + 1; j < arr.size(); j++) {
if (arr.get(i).equals(arr.get(j))) {
arr.remove(j);
j –; // Adjust the loop index after removal
count ++;
}
}
System.out.printf("%d occurs %d times", arr.get(i), count);
System.out.println();
}
}
}
Code for 2nd Que in Python
s=input(“s= “)
res=””
c=1
a=len(s)-1
for i in range(len(s)-1):
if s[i]==s[i+1]:
c=c+1
else:
res+=s[i]+str(c)
i=c
c=1
res+=s[a]+str(c)
print(“\n”,res)
Question 6: simplified
n=int(input())
s=0
for i in range(n):
x,y=map(int,input().split())
s=s+(x*4)+(y*2)
print(s)
l=list(map(int,input().split(” “)))
l.sort()
d=list(set(l))
for i in d:
print(i,”occurs”,l.count(i),”times”)
import java.util.*;
class Asif {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
LinkedHashMap mapp = new LinkedHashMap();
for(int i = 0; i
System.out.print(k+””+v));}
}
problem-2
s=input(“Enter the string:\n”)
l1=list(s)
l=[]
for i in l1:
if i not in l:
l.append(i)
x=l1.count(i)
if x>1:
l.append(str(x))
n=”
for i in l:
n=n+i
print(n)
problem:1
s=input(“Enter the string\n”)
x=s.count(“#”)
y=s.replace(“#”,””,x)
print(“#”*x+y)
import java.util.*;
public class Dealers {
public static void main(String[] args) {
int [][] a = {
{4,2},
{4,0},
{1,2}
};
List ans = calc(a, 3);
for(int i: ans)
System.out.print(i+” “);
}
private static List calc(int a[][], int n){
List ans = new ArrayList();
for(int i=0; i<n; i++){
int cars = a[i][0];
int bikes = a[i][1];
int tyres = (cars * 4) + (bikes * 2);
ans.add(tyres);
}
return ans;
}
}