Capgemini Placement Papers 2024
Capgemini Coding Questions 2025 - Game-Based & Hands-on Coding Problems
Practice 25+ Capgemini placement paper coding questions with detailed solutions. Access Capgemini game-based assessment and hands-on coding problems in C, C++, Java, Python for Capgemini placement 2025-2026.
Capgemini Placement Paper Coding Questions - Complete Guide
Section titled “Capgemini Placement Paper Coding Questions - Complete Guide”Practice with 25+ Capgemini placement paper coding questions covering the Capgemini game-based assessment and hands-on coding test. These questions are representative of what you’ll encounter in Capgemini’s online assessment.
What’s Included:
- 25+ Coding Problems: Easy and Medium level problems with solutions
- Multiple Language Solutions: C, C++, Java, and Python solutions
- Time Complexity Analysis: Every solution includes complexity analysis
- Capgemini-Specific Patterns: Focus on pseudocode, basic programming, arrays, strings
Capgemini Placement Papers 2025
Complete Capgemini Guide
Access complete Capgemini placement papers guide with eligibility, process, and preparation strategy.
Capgemini Coding Section Overview
Section titled “Capgemini Coding Section Overview”Capgemini Assessment Coding Section Breakdown:
| Section | Questions | Time | Difficulty | Focus Areas |
|---|---|---|---|---|
| Game-Based (Pseudocode) | 15 MCQs | 25 min | Easy-Medium | Pseudocode, logic, tracing |
| Hands-on Coding | 2 | 45 min | Easy-Medium | Arrays, strings, basic algorithms |
Languages Allowed: C, C++, Java, Python
Pseudocode Practice Questions
Section titled “Pseudocode Practice Questions”Q1: Loop Output Prediction
Question: What is the output of the following pseudocode?
SET x = 5SET y = 0WHILE x > 0 DO SET y = y + x SET x = x - 1ENDWHILEPRINT yOptions:
- A) 10
- B) 15
- C) 20
- D) 5
Answer: B) 15
Explanation:
- x=5: y = 0+5 = 5, x = 4
- x=4: y = 5+4 = 9, x = 3
- x=3: y = 9+3 = 12, x = 2
- x=2: y = 12+2 = 14, x = 1
- x=1: y = 14+1 = 15, x = 0
- Loop ends, y = 15
Q2: Conditional Statement
Question: What is the output?
SET a = 10SET b = 20IF a > b THEN PRINT aELSE IF a == 10 THEN PRINT b + a ELSE PRINT b - a ENDIFENDIFOptions:
- A) 10
- B) 20
- C) 30
- D) -10
Answer: C) 30
Explanation: a (10) is not > b (20), so else executes. a == 10 is true, so b + a = 30.
Q3: Array Traversal
Question: What is the output?
SET arr = [1, 2, 3, 4, 5]SET sum = 0FOR i = 0 TO 4 DO IF arr[i] MOD 2 == 0 THEN SET sum = sum + arr[i] ENDIFENDFORPRINT sumOptions:
- A) 6
- B) 9
- C) 15
- D) 5
Answer: A) 6
Explanation: Even numbers in array are 2 and 4. Sum = 2 + 4 = 6.
Q4: Nested Loop
Question: What is the output?
SET count = 0FOR i = 1 TO 3 DO FOR j = 1 TO i DO SET count = count + 1 ENDFORENDFORPRINT countOptions:
- A) 3
- B) 6
- C) 9
- D) 4
Answer: B) 6
Explanation:
- i=1: j runs 1 time (count=1)
- i=2: j runs 2 times (count=3)
- i=3: j runs 3 times (count=6)
Q5: String Operation
Question: What is the output?
SET str = "CAPGEMINI"SET count = 0FOR i = 0 TO LENGTH(str) - 1 DO IF str[i] == 'A' OR str[i] == 'E' OR str[i] == 'I' THEN SET count = count + 1 ENDIFENDFORPRINT countOptions:
- A) 2
- B) 3
- C) 4
- D) 5
Answer: C) 4
Explanation: Vowels in “CAPGEMINI”: A, E, I, I = 4 vowels.
Hands-on Coding Problems
Section titled “Hands-on Coding Problems”Sum of Array Elements
Problem: Find the sum of all elements in an array.
Example:
Input: [1, 2, 3, 4, 5]Output: 15Solution (Java):
public int arraySum(int[] arr) { int sum = 0; for (int num : arr) { sum += num; } return sum;}Solution (Python):
def array_sum(arr): return sum(arr)Solution (C):
int arraySum(int arr[], int n) { int sum = 0; for (int i = 0; i < n; i++) { sum += arr[i]; } return sum;}Time Complexity: O(n) | Space Complexity: O(1)
Find Second Largest
Problem: Find second largest element in array.
Example:
Input: [12, 35, 1, 10, 34]Output: 34Solution (Java):
public int secondLargest(int[] arr) { int first = Integer.MIN_VALUE; int second = Integer.MIN_VALUE;
for (int num : arr) { if (num > first) { second = first; first = num; } else if (num > second && num != first) { second = num; } } return second;}Solution (Python):
def second_largest(arr): first = second = float('-inf') for num in arr: if num > first: second = first first = num elif num > second and num != first: second = num return secondTime Complexity: O(n) | Space Complexity: O(1)
Reverse Array
Problem: Reverse an array in-place.
Example:
Input: [1, 2, 3, 4, 5]Output: [5, 4, 3, 2, 1]Solution (Java):
public void reverseArray(int[] arr) { int left = 0, right = arr.length - 1; while (left < right) { int temp = arr[left]; arr[left] = arr[right]; arr[right] = temp; left++; right--; }}Solution (Python):
def reverse_array(arr): left, right = 0, len(arr) - 1 while left < right: arr[left], arr[right] = arr[right], arr[left] left += 1 right -= 1Time Complexity: O(n) | Space Complexity: O(1)
Find Duplicates
Problem: Find duplicate elements in array.
Solution (Java):
public List<Integer> findDuplicates(int[] arr) { Set<Integer> seen = new HashSet<>(); List<Integer> duplicates = new ArrayList<>();
for (int num : arr) { if (seen.contains(num)) { if (!duplicates.contains(num)) { duplicates.add(num); } } else { seen.add(num); } } return duplicates;}Solution (Python):
def find_duplicates(arr): seen = set() duplicates = set() for num in arr: if num in seen: duplicates.add(num) seen.add(num) return list(duplicates)Time Complexity: O(n) | Space Complexity: O(n)
Rotate Array
Problem: Rotate array to the left by k positions.
Example:
Input: arr = [1, 2, 3, 4, 5], k = 2Output: [3, 4, 5, 1, 2]Solution (Java):
public void rotateLeft(int[] arr, int k) { int n = arr.length; k = k % n; reverse(arr, 0, k - 1); reverse(arr, k, n - 1); reverse(arr, 0, n - 1);}
private void reverse(int[] arr, int start, int end) { while (start < end) { int temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; }}Solution (Python):
def rotate_left(arr, k): n = len(arr) k = k % n return arr[k:] + arr[:k]Time Complexity: O(n) | Space Complexity: O(1)
Reverse String
Problem: Reverse a given string.
Example:
Input: "hello"Output: "olleh"Solution (Java):
public String reverseString(String s) { char[] chars = s.toCharArray(); int left = 0, right = chars.length - 1; while (left < right) { char temp = chars[left]; chars[left] = chars[right]; chars[right] = temp; left++; right--; } return new String(chars);}Solution (Python):
def reverse_string(s): return s[::-1]Time Complexity: O(n) | Space Complexity: O(n)
Palindrome Check
Problem: Check if a string is palindrome.
Example:
Input: "madam"Output: trueSolution (Java):
public boolean isPalindrome(String s) { s = s.toLowerCase(); int left = 0, right = s.length() - 1; while (left < right) { if (s.charAt(left) != s.charAt(right)) { return false; } left++; right--; } return true;}Solution (Python):
def is_palindrome(s): s = s.lower() return s == s[::-1]Time Complexity: O(n) | Space Complexity: O(1)
Count Vowels and Consonants
Problem: Count vowels and consonants in a string.
Solution (Java):
public int[] countVowelsConsonants(String s) { int vowels = 0, consonants = 0; s = s.toLowerCase(); for (char c : s.toCharArray()) { if (Character.isLetter(c)) { if ("aeiou".indexOf(c) != -1) { vowels++; } else { consonants++; } } } return new int[]{vowels, consonants};}Solution (Python):
def count_vowels_consonants(s): vowels = set('aeiouAEIOU') v = c = 0 for char in s: if char.isalpha(): if char in vowels: v += 1 else: c += 1 return v, cTime Complexity: O(n) | Space Complexity: O(1)
Anagram Check
Problem: Check if two strings are anagrams.
Example:
Input: s1 = "listen", s2 = "silent"Output: trueSolution (Java):
public boolean isAnagram(String s1, String s2) { if (s1.length() != s2.length()) return false; int[] count = new int[26]; for (int i = 0; i < s1.length(); i++) { count[s1.charAt(i) - 'a']++; count[s2.charAt(i) - 'a']--; } for (int c : count) { if (c != 0) return false; } return true;}Solution (Python):
def is_anagram(s1, s2): return sorted(s1.lower()) == sorted(s2.lower())Time Complexity: O(n) | Space Complexity: O(1)
Remove Duplicates from String
Problem: Remove duplicate characters from string.
Example:
Input: "programming"Output: "progamin"Solution (Java):
public String removeDuplicates(String s) { StringBuilder result = new StringBuilder(); Set<Character> seen = new LinkedHashSet<>(); for (char c : s.toCharArray()) { if (!seen.contains(c)) { seen.add(c); result.append(c); } } return result.toString();}Solution (Python):
def remove_duplicates(s): seen = set() result = [] for char in s: if char not in seen: seen.add(char) result.append(char) return ''.join(result)Time Complexity: O(n) | Space Complexity: O(n)
Prime Number Check
Problem: Determine if a number is prime.
Solution (Java):
public boolean isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i += 6) { if (n % i == 0 || n % (i + 2) == 0) return false; } return true;}Solution (Python):
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return TrueTime Complexity: O(√n) | Space Complexity: O(1)
Factorial
Problem: Calculate factorial.
Solution (Java):
public long factorial(int n) { if (n <= 1) return 1; long result = 1; for (int i = 2; i <= n; i++) { result *= i; } return result;}Solution (Python):
def factorial(n): result = 1 for i in range(2, n + 1): result *= i return resultTime Complexity: O(n) | Space Complexity: O(1)
Fibonacci Series
Problem: Generate Fibonacci series up to n terms.
Solution (Java):
public int[] fibonacci(int n) { if (n <= 0) return new int[]{}; int[] fib = new int[n]; fib[0] = 0; if (n > 1) fib[1] = 1; for (int i = 2; i < n; i++) { fib[i] = fib[i-1] + fib[i-2]; } return fib;}Solution (Python):
def fibonacci(n): if n <= 0: return [] fib = [0, 1] for i in range(2, n): fib.append(fib[-1] + fib[-2]) return fib[:n]Time Complexity: O(n) | Space Complexity: O(n)
GCD of Two Numbers
Problem: Find GCD using Euclidean algorithm.
Solution (Java):
public int gcd(int a, int b) { while (b != 0) { int temp = b; b = a % b; a = temp; } return a;}Solution (Python):
def gcd(a, b): while b: a, b = b, a % b return aTime Complexity: O(log(min(a,b))) | Space Complexity: O(1)
Armstrong Number
Problem: Check if number is Armstrong number.
Example:
Input: 153Output: true (1³ + 5³ + 3³ = 153)Solution (Java):
public boolean isArmstrong(int n) { int original = n; int digits = String.valueOf(n).length(); int sum = 0; while (n > 0) { int digit = n % 10; sum += Math.pow(digit, digits); n /= 10; } return sum == original;}Solution (Python):
def is_armstrong(n): digits = len(str(n)) return sum(int(d)**digits for d in str(n)) == nTime Complexity: O(d) | Space Complexity: O(1)
Practice Tips for Capgemini Assessment
Section titled “Practice Tips for Capgemini Assessment”Master Pseudocode
- Practice tracing code
- Understand loops and conditionals
- Know array indexing
- Read carefully for edge cases
Master One Language
- Choose C, C++, Java, or Python
- Know standard library functions
- Practice writing code quickly
- Handle I/O properly
Time Management
- Pseudocode: ~1.5 min/question
- Coding: ~20 min/problem
- Read problem carefully
- Test with given examples
Common Mistakes to Avoid
- Off-by-one errors
- Not handling empty inputs
- Wrong output format
- Not considering edge cases
Related Resources
Section titled “Related Resources”Capgemini 2024 Papers
Previous year papers with coding questions
Capgemini 2025 Papers
Latest papers with current year questions
Capgemini Aptitude Questions
Aptitude questions with solutions
Capgemini Interview Experience
Real interview experiences
Capgemini Preparation Guide
Comprehensive preparation strategy
Capgemini Main Page
Complete Capgemini placement guide
Practice Capgemini coding questions regularly! Focus on pseudocode for game-based assessment and basic programming for hands-on coding. Capgemini values working code that handles all test cases.
Pro Tip: Don’t underestimate the pseudocode section - it’s a significant part of the assessment. Practice tracing code outputs carefully.
Last updated: February 2026