CG - Coding
CG - Coding
Question – 01.
Problem Statement –
You have write a function that accepts, a string which length is “len”, the string has some “#”, in it you have to move all
the hashes to the front of the string and return the whole string back and print it.
example :-
Input:
Move#Hash#to#Front
Output:
###MoveHashtoFront
In C:
In C++:
In Java:
Question – 02.
Problem Statement –
Capgemini in its online written test have a coding question, wherein the students are given a string with multiple
characters that 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
In C:
Question – 03.
Problem Statement –
Sample Input
Input
5 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
Output
1 2 3 4 8 12 16 20 19 18 17 13 9 5 6 7 11 15 12 14 10
Question – 04.
Problem Statement –
You’re given an array of integers, print the number of times each integer has occurred in the array.
Example
Input :
10
1233414512
Output :
1 occurs 3 times
2 occurs 2 times
3 occurs 2 times
4 occurs 2 times
5 occurs 1 times
Question – 05.
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.
Question – 06.
Problem Statement –
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.
Input
42
40
12
Output
20
16