Capgemini Coding Interview Questions 2024-2026: 10 Real Problems with Solutions
Prepare for Capgemini coding interviews with real questions asked in 2024-2026 technical rounds. Includes detailed solutions in C++, test cases, and explanations for arrays, strings, and logic-building problems.
Capgemini Coding Interview Questions 2024-2026: 10 Real Problems with Solutions
Preparing for a Capgemini coding interview? This comprehensive guide covers 10 real coding questions asked in Capgemini technical interviews during 2024-2026. Each problem includes detailed explanations, multiple test cases, and optimized C++ solutions.
What to Expect in Capgemini Coding Rounds
Capgemini technical interviews typically focus on:
Array manipulation and basic data structures
String processing and pattern recognition
Logic building and mathematical problems
Basic DSA concepts like sorting and hashing
Time complexity optimization
Most questions are easy to medium difficulty, testing your problem-solving fundamentals rather than advanced algorithms.
Calculate the "Reverse ASCII Sum" of a lowercase string where each character gets a reverse alphabetical value ('a'=26, 'b'=25, ..., 'z'=1), multiplied by its position (1-indexed), then summed.
Input/Output
Input: A lowercase English string Output: Integer representing the Reverse ASCII Sum
Constraints
String contains only lowercase letters ('a'-'z')
Length: 1 to 1000 characters
Test Cases
Test Case 1:
code
Input: abc
Output: 148
Explanation:
'a' at position 1: reverse value = 26, contribution = 1×26 = 26
'b' at position 2: reverse value = 25, contribution = 2×25 = 50
'c' at position 3: reverse value = 24, contribution = 3×24 = 72
Total: 26 + 50 + 72 = 148
Test Case 2:
code
Input: z
Output: 1
Solution in C++
cpp
#include <iostream>#include <string>using namespace std;int main() { string s; cin >> s; int sum = 0; for (int i = 0; i < s.length(); i++) { int reverseVal = 'z' - s[i] + 1; sum += (i + 1) * reverseVal; } cout << sum << endl; return 0;}
Time Complexity: O(n) Space Complexity: O(1)
2. Lexicographically Smallest String from Permutations
#include <iostream>#include <vector>using namespace std;int main() { int N, X, Y; cin >> N; vector<pair<int, int>> segments(N); for (int i = 0; i < N; i++) { cin >> segments[i].first >> segments[i].second; } cin >> X >> Y; int total = 0; for (int p = X; p <= Y; p++) { for (auto
Time Complexity: O((Y-X) × N) Space Complexity: O(N)
4. Virus Detection in Mobile Strings
Difficulty: Easy Topics: String Patterns, Logic Building
Problem Statement
Detect if a mobile contains a virus. A string is infected (special string) if all characters at alternative positions starting from index 0 are the same.
Input/Output
Input:
N (number of strings)
N strings
Output: 1 if infected, 0 otherwise (for each string)
#include <iostream>using namespace std;int sumDigits(long long n) { int sum = 0; while (n > 0) { sum += n % 10; n /= 10; } return sum;}int main() { long long A, B; cin >> A >> B; long long total = 0; for (long long i = A; i <= B; ++i) {
Time Complexity: O((B-A) × log(B)) Space Complexity: O(1)
7. Array Left Rotation
Difficulty: Easy Topics: Arrays, Rotation
Problem Statement
Rotate an array to the left by d positions.
Input/Output
Input:
n (array size)
n integers (array elements)
d (rotation count)
Output: Rotated array
Test Cases
Test Case 1:
code
Input:
5
1 3 5 7 9
2
Output: 5 7 9 1 3
Test Case 2:
code
Input:
4
10 20 30 40
0
Output: 10 20 30 40
Solution in C++
cpp
#include <iostream>#include <vector>using namespace std;void rotate(vector<int>& arr, int d, int n) { d = d % n; vector<int> rotated; for (int i = d; i < n; ++i) rotated.push_back(arr[i]); for (int i = 0; i < d; ++i) rotated.push_back(arr[i]); for (int i = 0; i < n;
Time Complexity: O(n) Space Complexity: O(n)
8. Move All Hashes to Front
Difficulty: Easy Topics: String Manipulation
Problem Statement
Move all '#' characters to the front of the string while maintaining the order of other characters.
Complexity analysis: Understand time and space complexity of your solutions
Common Patterns in Capgemini Questions
Character manipulation with mathematical operations
Array transformations and rearrangements
Simple mathematical formulas applied to programming
Pattern recognition in strings
Frequency counting and hashing
Conclusion
These 10 Capgemini coding interview questions represent the actual problems asked in technical rounds during 2024-2026. The key to success is understanding fundamental concepts and practicing similar problems regularly.
Pro tip: Don't just memorize solutions understand the logic behind each approach. Interviewers often ask follow-up questions or variations of these problems.
Good luck with your Capgemini interview preparation!