Cognizant Placement Papers 2024
Access 2024 Cognizant GenC/Pro/Elevate questions with solutions and exam pattern analysis.
Practice 25+ Cognizant placement paper coding questions with detailed solutions. Access Cognizant GenC, GenC Pro, GenC Elevate coding problems in C, C++, Java, Python for Cognizant placement 2025-2026.
Practice with 25+ Cognizant placement paper coding questions covering the Cognizant GenC, GenC Pro, and GenC Elevate online assessment. These questions are representative of what you’ll encounter in Cognizant’s coding test.
What’s Included:
Cognizant Placement Papers 2024
Access 2024 Cognizant GenC/Pro/Elevate questions with solutions and exam pattern analysis.
Cognizant Placement Papers 2025
Complete Cognizant Guide
Access complete Cognizant placement papers guide with eligibility, process, and preparation strategy.
Cognizant Assessment Coding Section by Role:
| Role | Problems | Time | Difficulty | Focus Areas |
|---|---|---|---|---|
| GenC | 1-2 | 30 min | Easy | Basic programming, arrays, strings |
| GenC Pro | 2 | 45 min | Medium | DSA, recursion, sorting |
| GenC Elevate | 2-3 | 60 min | Medium-Hard | Advanced DSA, DP, graphs |
Languages Allowed: C, C++, Java, Python
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)
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)
Problem: Determine if a number is prime.
Example:
Input: 17Output: trueSolution (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)
Problem: Calculate factorial of a number.
Example:
Input: 5Output: 120Solution (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)
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)
Problem: Find maximum element in array.
Solution (Java):
public int findMax(int[] arr) { int max = arr[0]; for (int num : arr) { if (num > max) max = num; } return max;}Solution (Python):
def find_max(arr): return max(arr)Time Complexity: O(n) | Space Complexity: O(1)
Problem: Count vowels in a string.
Solution (Java):
public int countVowels(String s) { int count = 0; s = s.toLowerCase(); for (char c : s.toCharArray()) { if ("aeiou".indexOf(c) != -1) count++; } return count;}Solution (Python):
def count_vowels(s): return sum(1 for c in s.lower() if c in 'aeiou')Time Complexity: O(n) | Space Complexity: O(1)
Problem: Find indices of two numbers that add up to target.
Example:
Input: nums = [2, 7, 11, 15], target = 9Output: [0, 1]Solution (Java):
public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { int complement = target - nums[i]; if (map.containsKey(complement)) { return new int[]{map.get(complement), i}; } map.put(nums[i], i); } return new int[]{};}Solution (Python):
def two_sum(nums, target): seen = {} for i, num in enumerate(nums): if target - num in seen: return [seen[target - num], i] seen[num] = i return []Time Complexity: O(n) | Space Complexity: O(n)
Problem: Find the second largest element without sorting.
Solution (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)
Problem: Check if string with brackets is valid.
Solution (Java):
public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); Map<Character, Character> map = Map.of(')', '(', '}', '{', ']', '[');
for (char c : s.toCharArray()) { if (map.containsKey(c)) { if (stack.isEmpty() || stack.pop() != map.get(c)) return false; } else { stack.push(c); } } return stack.isEmpty();}Time Complexity: O(n) | Space Complexity: O(n)
Problem: Reverse the order of words in a string.
Solution (Java):
public String reverseWords(String s) { String[] words = s.trim().split("\\s+"); StringBuilder result = new StringBuilder(); for (int i = words.length - 1; i >= 0; i--) { result.append(words[i]); if (i > 0) result.append(" "); } return result.toString();}Solution (Python):
def reverse_words(s): return ' '.join(s.split()[::-1])Time Complexity: O(n) | Space Complexity: O(n)
Problem: Find element in sorted array using binary search.
Solution (Java):
public int binarySearch(int[] arr, int target) { int left = 0, right = arr.length - 1;
while (left <= right) { int mid = left + (right - left) / 2; if (arr[mid] == target) return mid; if (arr[mid] < target) left = mid + 1; else right = mid - 1; } return -1;}Solution (Python):
def binary_search(arr, target): left, right = 0, len(arr) - 1 while left <= right: mid = (left + right) // 2 if arr[mid] == target: return mid elif arr[mid] < target: left = mid + 1 else: right = mid - 1 return -1Time Complexity: O(log n) | Space Complexity: O(1)
Problem: Merge two sorted arrays into one sorted array.
Solution (Java):
public int[] mergeSorted(int[] arr1, int[] arr2) { int[] result = new int[arr1.length + arr2.length]; int i = 0, j = 0, k = 0;
while (i < arr1.length && j < arr2.length) { if (arr1[i] <= arr2[j]) { result[k++] = arr1[i++]; } else { result[k++] = arr2[j++]; } } while (i < arr1.length) result[k++] = arr1[i++]; while (j < arr2.length) result[k++] = arr2[j++];
return result;}Time Complexity: O(n+m) | Space Complexity: O(n+m)
Problem: Find length of longest substring without repeating characters.
Solution (Java):
public int lengthOfLongestSubstring(String s) { Map<Character, Integer> seen = new HashMap<>(); int maxLen = 0, left = 0;
for (int right = 0; right < s.length(); right++) { char c = s.charAt(right); if (seen.containsKey(c) && seen.get(c) >= left) { left = seen.get(c) + 1; } seen.put(c, right); maxLen = Math.max(maxLen, right - left + 1); } return maxLen;}Time Complexity: O(n) | Space Complexity: O(min(m,n))
Problem: Find contiguous subarray with largest sum.
Solution (Java):
public int maxSubArray(int[] nums) { int maxSoFar = nums[0]; int maxEndingHere = nums[0];
for (int i = 1; i < nums.length; i++) { maxEndingHere = Math.max(nums[i], maxEndingHere + nums[i]); maxSoFar = Math.max(maxSoFar, maxEndingHere); } return maxSoFar;}Time Complexity: O(n) | Space Complexity: O(1)
Problem: Count ways to climb n stairs (1 or 2 steps).
Solution (Java):
public int climbStairs(int n) { if (n <= 2) return n; int prev2 = 1, prev1 = 2; for (int i = 3; i <= n; i++) { int curr = prev1 + prev2; prev2 = prev1; prev1 = curr; } return prev1;}Solution (Python):
def climb_stairs(n): if n <= 2: return n prev2, prev1 = 1, 2 for i in range(3, n + 1): curr = prev1 + prev2 prev2, prev1 = prev1, curr return prev1Time Complexity: O(n) | Space Complexity: O(1)
Problem: Find minimum coins to make amount.
Solution (Java):
public int coinChange(int[] coins, int amount) { int[] dp = new int[amount + 1]; Arrays.fill(dp, amount + 1); dp[0] = 0;
for (int i = 1; i <= amount; i++) { for (int coin : coins) { if (coin <= i) { dp[i] = Math.min(dp[i], dp[i - coin] + 1); } } } return dp[amount] > amount ? -1 : dp[amount];}Time Complexity: O(amount × coins) | Space Complexity: O(amount)
Problem: Count islands in a 2D grid.
Solution (Java):
public int numIslands(char[][] grid) { int count = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[0].length; j++) { if (grid[i][j] == '1') { dfs(grid, i, j); count++; } } } return count;}
private void dfs(char[][] grid, int i, int j) { if (i < 0 || i >= grid.length || j < 0 || j >= grid[0].length || grid[i][j] == '0') return; grid[i][j] = '0'; dfs(grid, i+1, j); dfs(grid, i-1, j); dfs(grid, i, j+1); dfs(grid, i, j-1);}Time Complexity: O(m×n) | Space Complexity: O(m×n)
Problem: Find length of LCS of two strings.
Solution (Java):
public int longestCommonSubsequence(String text1, String text2) { int m = text1.length(), n = text2.length(); int[][] dp = new int[m + 1][n + 1];
for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (text1.charAt(i-1) == text2.charAt(j-1)) { dp[i][j] = dp[i-1][j-1] + 1; } else { dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]); } } } return dp[m][n];}Time Complexity: O(m×n) | Space Complexity: O(m×n)
Know Your Role
Master One Language
Time Management
Common Mistakes to Avoid
Cognizant 2024 Papers
Previous year papers with coding questions
Cognizant 2025 Papers
Latest papers with current year questions
Cognizant Aptitude Questions
Aptitude questions with solutions
Cognizant Interview Experience
Real interview experiences
Cognizant Preparation Guide
Comprehensive preparation strategy
Cognizant Main Page
Complete Cognizant placement guide
Practice Cognizant coding questions regularly! Focus on problems matching your target role (GenC/Pro/Elevate). Cognizant values working code that handles all test cases.
Pro Tip: For GenC Elevate, also prepare for behavioral and case study rounds along with coding.
Last updated: February 2026