Capgemini Most Asked Coding Questions -
Question Bank Only
Document Information
Total Questions: 100+ actual coding questions
Source: Capgemini interviews and assessments (2020-2025)
Frequency: Arranged by occurrence rate
Time: 45 minutes for 2 questions in actual exam
Part 1: Array Problems (Very High Frequency)
Question 1: Find Largest and Smallest in Array ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5-8 minutes
Problem Statement
Find the largest and smallest elements in an array of integers.
Input Format
5
3 8 1 9 4
Output Format
Largest: 9
Smallest: 1
Test Cases
Input: [5, 2, 8, 1, 9] → Output: Largest: 9, Smallest: 1
Input: [10] → Output: Largest: 10, Smallest: 10
Question 2: Reverse an Array ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5 minutes
Problem Statement
Reverse the elements of an array in-place without using extra space.
Input Format
5
1 2 3 4 5
Output Format
5 4 3 2 1
Test Cases
Input: [1, 2, 3, 4, 5] → Output: [5, 4, 3, 2, 1]
Input: [7, 8] → Output: [8, 7]
Question 3: Find All Pairs with Given Sum ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-15 minutes
Problem Statement
Find all pairs in an array whose sum equals a given target number. Print each pair only once.
Input Format
6
1 5 7 -1 5 9
6
Output Format
(1, 5)
(7, -1)
Test Cases
Array: [1, 5, 7, -1, 5, 9], Target: 6 → Pairs: (1,5), (7,-1)
Array: [2, 7, 11, 15], Target: 9 → Pairs: (2,7)
Question 4: Missing Number in Array ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5-8 minutes
Problem Statement
You have an array of size n-1 containing numbers from 1 to n. Find the missing number.
Input Format
5
1 2 4 5
Output Format
Missing number: 3
Test Cases
Input: [1, 2, 4, 5] (n=5) → Output: 3
Input: [2, 3, 4, 5, 6] (n=6) → Output: 1
Question 5: Maximum Sum Subarray (Kadane's Algorithm) ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Find the contiguous subarray with the maximum sum and return the sum.
Input Format
6
-2 1 -3 4 5 -1
Output Format
Maximum sum: 8
Explanation
The subarray [4, 5] has the maximum sum of 8.
Test Cases
Input: [-2, 1, -3, 4, 5, -1] → Output: 8
Input: [1, 2, 3, 4] → Output: 10
Question 6: Rotate Array by K Positions ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Rotate an array to the right by k positions.
Input Format
7
1 2 3 4 5 6 7
3
Output Format
5 6 7 1 2 3 4
Test Cases
Array: [1,2,3,4,5,6,7], k=3 → Output: [5,6,7,1,2,3,4]
Array: [1,2], k=1 → Output: [2,1]
Question 7: Find Duplicate Elements ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 8-10 minutes
Problem Statement
Find and print all duplicate elements in an array.
Input Format
8
1 2 3 2 4 5 3 6
Output Format
Duplicate elements: 2 3
Test Cases
Input: [1,2,3,2,4,5,3,6] → Output: 2, 3
Input: [1,1,1,2,2] → Output: 1, 2
Question 8: Rearrange Positive and Negative Numbers ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 12-15 minutes
Problem Statement
Rearrange array so that positive and negative numbers appear alternately.
Input Format
6
1 -2 3 -4 5 -6
Output Format
1 -2 3 -4 5 -6
Test Cases
Input: [1,-2,3,-4,5,-6] → Output: [1,-2,3,-4,5,-6]
Input: [-1,2,-3,4] → Output: [2,-1,4,-3]
Part 2: String Problems (Very High Frequency)
Question 9: Check Palindrome String ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5-8 minutes
Problem Statement
Check if a string reads the same forward and backward (case-sensitive).
Input Format
racecar
Output Format
Palindrome
Test Cases
Input: "racecar" → Output: Palindrome
Input: "hello" → Output: Not a palindrome
Question 10: Count Character Frequency ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 8-10 minutes
Problem Statement
Count the frequency of each character in a string and display the results.
Input Format
programming
Output Format
p appears 1 times
r appears 2 times
o appears 1 times
g appears 2 times
a appears 1 times
m appears 2 times
i appears 1 times
n appears 1 times
Test Cases
Input: "programming" → Count each character
Input: "aab" → a:2, b:1
Question 11: Remove Duplicate Characters ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 8-12 minutes
Problem Statement
Remove duplicate characters from a string while maintaining the original order of first occurrence.
Input Format
programming
Output Format
progamin
Test Cases
Input: "programming" → Output: "progamin"
Input: "hello" → Output: "helo"
Question 12: String Compression ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Medium | Time: 12-15 minutes
Problem Statement
Compress a string by replacing consecutive characters with character followed by count. If count is 1, don't add the count.
Input Format
aabbbbeeeeffggg
Output Format
a2b4e4f2g3
Test Cases
Input: "aabbbbeeeeffggg" → Output: "a2b4e4f2g3"
Input: "abcdef" → Output: "abcdef"
Question 13: Move Special Characters to Front ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Move all '#' characters to the front of the string while maintaining the order of other characters.
Input Format
Move#Hash#to#Front
Output Format
###MoveHashtoFront
Test Cases
Input: "Move#Hash#to#Front" → Output: "###MoveHashtoFront"
Input: "a#b#c" → Output: "##abc"
Question 14: First Non-Repeated Character ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Find the first non-repeated character in a string.
Input Format
programming
Output Format
First non-repeated character: p
Test Cases
Input: "programming" → Output: 'p'
Input: "aabbcc" → Output: No non-repeated character
Question 15: String Rotation Check ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 12-15 minutes
Problem Statement
Check if one string is a rotation of another string.
Input Format
waterbottle
erbottlewat
Output Format
Yes, second string is rotation of first
Test Cases
Input: "waterbottle", "erbottlewat" → Output: Yes
Input: "abcde", "cdeab" → Output: Yes
Question 16: Replace Consonants with Nearest Vowels ⭐⭐⭐⭐
Frequency: High | Difficulty: Hard | Time: 15-20 minutes
Problem Statement
Replace each consonant with the nearest vowel. If a consonant is equidistant from two vowels, choose the one that comes
first alphabetically.
Vowels: a, e, i, o, u
Input Format
codebashers
Output Format
aoeeaoheis
Explanation
c → a (distance 2 from both a and e, choose a)
o → o (vowel, unchanged)
d → e (distance 1 from e)
e → e (vowel, unchanged)
Test Cases
Input: "codebashers" → Output: "aoeeaoheis"
Input: "hello" → Output: "eeooo"
Part 3: Mathematical Problems (Very High
Frequency)
Question 17: Check Prime Number ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5-8 minutes
Problem Statement
Determine if a given number is prime (divisible only by 1 and itself).
Input Format
17
Output Format
17 is a prime number
Test Cases
Input: 17 → Output: Prime
Input: 15 → Output: Not prime
Question 18: Sum of Remainders ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Medium | Time: 8-10 minutes
Problem Statement
Calculate the sum of remainders when numbers from 1 to n are divided by a given divisor.
Input Format
12
4
Output Format
Sum of remainders: 18
Explanation
1%4=1, 2%4=2, 3%4=3, 4%4=0, 5%4=1, 6%4=2, 7%4=3, 8%4=0, 9%4=1, 10%4=2, 11%4=3, 12%4=0
Sum = 1+2+3+0+1+2+3+0+1+2+3+0 = 18
Test Cases
Input: n=12, div=4 → Output: 18
Input: n=10, div=3 → Output: 18
Question 19: Fibonacci Series ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5-8 minutes
Problem Statement
Generate the first n Fibonacci numbers.
Input Format
Output Format
0 1 1 2 3 5 8
Test Cases
Input: 7 → Output: 0 1 1 2 3 5 8
Input: 5 → Output: 0 1 1 2 3
Question 20: Reverse a Number ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Easy | Time: 5 minutes
Problem Statement
Reverse the digits of a given positive integer.
Input Format
12345
Output Format
54321
Test Cases
Input: 12345 → Output: 54321
Input: 100 → Output: 1
Question 21: Factorial using Recursion ⭐⭐⭐⭐
Frequency: High | Difficulty: Easy | Time: 5-8 minutes
Problem Statement
Calculate the factorial of a number using recursion.
Input Format
Output Format
Factorial of 5 is 120
Test Cases
Input: 5 → Output: 120
Input: 0 → Output: 1
Question 22: GCD using Euclidean Algorithm ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 8-10 minutes
Problem Statement
Find the Greatest Common Divisor (GCD) of two numbers using the Euclidean algorithm.
Input Format
48
18
Output Format
GCD is 6
Test Cases
Input: 48, 18 → Output: 6
Input: 17, 13 → Output: 1
Question 23: Armstrong Number Check ⭐⭐⭐⭐
Frequency: High | Difficulty: Easy | Time: 8-10 minutes
Problem Statement
Check if a number is an Armstrong number (sum of cubes of digits equals the number).
Input Format
153
Output Format
153 is an Armstrong number
Explanation
1³ + 5³ + 3³ = 1 + 125 + 27 = 153
Test Cases
Input: 153 → Output: Armstrong number
Input: 123 → Output: Not an Armstrong number
Question 24: Count Tyres in Dealership ⭐⭐⭐⭐
Frequency: High | Difficulty: Easy | Time: 5 minutes
Problem Statement
Calculate the total number of tyres in a dealership with cars (4 tyres each) and bikes (2 tyres each).
Input Format
5
3
Output Format
Total tyres: 26
Test Cases
Input: 5 cars, 3 bikes → Output: 26 tyres
Input: 2 cars, 4 bikes → Output: 16 tyres
Part 4: Matrix Problems (High Frequency)
Question 25: Spiral Matrix Traversal ⭐⭐⭐⭐⭐
Frequency: Very High | Difficulty: Medium | Time: 15-20 minutes
Problem Statement
Traverse a 2D matrix in spiral order (clockwise from outside to inside).
Input Format
3 4
1 2 3 4
5 6 7 8
9 10 11 12
Output Format
1 2 3 4 8 12 11 10 9 5 6 7
Test Cases
3x4 matrix → Output: 1 2 3 4 8 12 11 10 9 5 6 7
2x2 matrix → Output: 1 2 4 3
Question 26: Rotate Matrix 90 Degrees ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 15-18 minutes
Problem Statement
Rotate a square matrix 90 degrees clockwise in-place.
Input Format
3
1 2 3
4 5 6
7 8 9
Output Format
7 4 1
8 5 2
9 6 3
Test Cases
Input: [[1,2,3],[4,5,6],[7,8,9]] → Output: [[7,4,1],[8,5,2],[9,6,3]]
Question 27: Matrix Identity Check ⭐⭐⭐
Frequency: Medium | Difficulty: Easy | Time: 8-10 minutes
Problem Statement
Check if two matrices are identical (same dimensions and elements).
Input Format
2 3
1 2 3
4 5 6
1 2 3
4 5 6
Output Format
Matrices are identical
Test Cases
Same matrices → Output: Identical
Different matrices → Output: Not identical
Part 5: Stack and Queue Problems
Question 28: Balanced Parentheses ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-15 minutes
Problem Statement
Check if parentheses are balanced in a given string containing (), [], and {}.
Input Format
{[()]}
Output Format
Balanced
Test Cases
Input: "{[()]}" → Output: Balanced
Input: "{[(]}" → Output: Not balanced
Question 29: Next Greater Element ⭐⭐⭐
Frequency: Medium | Difficulty: Medium | Time: 12-15 minutes
Problem Statement
For each element in an array, find the next greater element to its right.
Input Format
4
4 5 2 25
Output Format
5 25 25 -1
Test Cases
Input: [4,5,2,25] → Output: [5,25,25,-1]
Input: [1,2,3,4] → Output: [2,3,4,-1]
Part 6: Searching and Sorting
Question 30: Binary Search ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Search for a target element in a sorted array using binary search.
Input Format
5
1 3 5 7 9
5
Output Format
Found at index: 2
Test Cases
Array: [1,3,5,7,9], Target: 5 → Output: Index 2
Array: [1,3,5,7,9], Target: 6 → Output: Not found
Question 31: Merge Two Sorted Arrays ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Merge two sorted arrays into one sorted array.
Input Format
3 4
1 3 5
2 4 6 8
Output Format
1 2 3 4 5 6 8
Test Cases
Array1: [1,3,5], Array2: [2,4,6,8] → Output: [1,2,3,4,5,6,8]
Part 7: Additional Problems
Question 32: Count Integer Occurrences ⭐⭐⭐⭐
Frequency: High | Difficulty: Easy-Medium | Time: 10-12 minutes
Problem Statement
Count and print the frequency of each integer in an array in order of first occurrence.
Input Format
7
1 2 3 2 1 4 2
Output Format
1 occurs 2 times
2 occurs 3 times
3 occurs 1 times
4 occurs 1 times
Question 33: Second Largest Element ⭐⭐⭐⭐
Frequency: High | Difficulty: Easy | Time: 8-10 minutes
Problem Statement
Find the second largest element in an array without sorting.
Input Format
5
12 35 1 10 34
Output Format
Second largest: 34
Question 34: Anagram Check ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium | Time: 10-12 minutes
Problem Statement
Check if two strings are anagrams (contain same characters with same frequency).
Input Format
listen
silent
Output Format
Anagrams
Question 35: Longest Palindromic Substring ⭐⭐⭐
Frequency: Medium | Difficulty: Hard | Time: 18-20 minutes
Problem Statement
Find the longest palindromic substring in a given string.
Input Format
babad
Output Format
Longest palindrome: bab
Part 8: Pseudocode Analysis Questions
Question 36: GCD Algorithm Analysis ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium
Pseudocode
Integer solve (Integer p, Integer q)
Integer value
while(q)
value = p MOD q
p = q
q = value
End while
return p
End function solve()
Question: What will be the output for solve(4, 2)?
Question 37: Bitwise Operations ⭐⭐⭐⭐
Frequency: High | Difficulty: Medium
Question
What is the result of the following operations?
5&3=?
5|3=?
5^3=?
5 >> 1 = ?
5 << 1 = ?
Question 38: Loop Analysis ⭐⭐⭐
Frequency: Medium | Difficulty: Medium
Pseudocode
sum = 0
for i = 1 to 5
for j = 1 to i
sum = sum + j
end for
end for
print sum
Question: What will be the final value of sum?
Practice Guidelines
Time Management
Easy Problems: 5-8 minutes
Medium Problems: 10-15 minutes
Hard Problems: 15-20 minutes
Frequency Priority
1. ⭐⭐⭐⭐⭐ Very High: Must solve (80-90% chance)
2. ⭐⭐⭐⭐ High: Should solve (60-80% chance)
3. ⭐⭐⭐ Medium: Good to solve (40-60% chance)
Categories by Importance
1. String Manipulation (85% frequency)
2. Array Operations (90% frequency)
3. Mathematical Problems (75% frequency)
4. Matrix Problems (60% frequency)
5. Stack/Queue (50% frequency)
Note: These are actual questions from Capgemini recruitment drives (2020-2025). Practice these systematically based on
frequency ratings for maximum impact.
Total Questions: 38 detailed problems covering all major categories. Focus on Very High and High frequency questions
first.