Professional Documents
Culture Documents
Cognizant Probable Sample Questions 2
Cognizant Probable Sample Questions 2
Cognizant Probable Sample Questions 2
Problem Statement :
2. You’re given a string where multiple characters 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
C++
JAVA
Python
C++
3. Problem Statement :
You are given an array of length “len” ,another item called k and an integer value x. Your
job is to find the sum of k farthest items in the array from x.
4, 15 and 11 are farthest from 20. Thus, their sum will be the answer.
C++
JAVA
Python
C++
4. Problem Statement :
Write a program to find the nth largest and nth smallest item in the array and print them
in the same line.
Input Format
The first line has the following –
Size of array, value of n
2nd line has the array
Output Format
Nth largest and nth smallest respectively
Input : Output :
63 34
123456
C++
JAVA
Python
C++
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.
C++
JAVA
Python
C++
6. Problem Statement :
In the city, there are a bunch of dealerships who sell bikes & cars. 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.