Capgemini Menu9>
- Placement Papers
- Pseudo Code
- English Communication Test
- Game Based Aptitude Test
- Behavioral Competency Test
- Game based Questions
- Syllabus
- Recruitment Process
- Game Based Cognitive Assessement
- Coding Questions
- Spoken English Test
- Interview Questions
- Capgemini Registration Process
- Exceller Interview Questions
- Essay Writing
PREPINSTA PRIME
Capgemini Exceller Coding Questions 2023
Capgemini Exceller Coding Questions and Answers 2023
Capgemini Exceller Coding Questions has been included as a new round in Capgemini Exceller selection process for 2023 graduates. This round will be conducted through CoCubes, containing 2 coding questions and you will have a total of 45 mins to solve. This round has been added to check the candidates programming, logical and problem solving techniques. Below we have given some previous year sample based questions for Capgemini Exceller Coding Round, make sure you practice all of them
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. The 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.
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>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); printf("%s",str1); } int main() { char a[100], len; scanf("%[^\n]s",a); len = strlen(a); moveHash(a, len); 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); } }
s=input() x=s.count("#") s=s.replace("#","") print("#"*x+s)
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; }
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); } } } }
def solve(s): ans="" c=1 for i in range(len(s)-1): if(s[i]==s[i+1]): c+=1 else: if(c==1): ans+=s[i] else: ans+=s[i]+str(c) c=1 if(c==1): ans+=s[i+1] else: ans+=s[i+1]+str(c) return anss=input() print(solve(s))
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, k=0; for(i=0;i<5;i++) { for(j=0;j<4;j++) { printf("%d\t",a[i][j]); } printf("\n"); } printf("\n"); while(rs { 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; }
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));
}
}
def spiralOrder(arr):
ans=[]
while arr:
ans+=arr.pop(0)
arr= (list(zip(*arr)))[::-1]
return ans
arr=[]
n,m=map(int,input().split())
for i in range(n):
arr.append(list(map(int,input().split())))
print(*spiralOrder(arr))
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
#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; }
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); } } }
n=int(input()) arr=list(map(int,input().split())) dup=[] for i in arr: if(i not in dup): dup.append(i) print("{} occurs {} times".format(i,arr.count(i)))
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; }
def spiralOrder(arr): ans=[] while arr: ans+=arr.pop(0) arr= (list(zip(*arr)))[::-1] return ans arr=[] n,m=map(int,input().split()) for i in range(n): arr.append(list(map(int,input().split()))) print(*spiralOrder(arr))
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
#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); } }
#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"; } }
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); } } }
for i in range(int(input())): cars,bikes=map(int,input().split()) print(cars*4+bikes*2)
30+ Companies are Hiring
Get Hiring Updates right in your inbox from PrepInsta
Login/Signup to comment