27 November 2014

Problem:

You are give N words. Length of each word<=10. You need to make them center aligned keeping max length as 10 ie a 6 letter word should be changed to 10 letter word by adding 2 spaces to right and 2 to left. If length is odd, then keep the word towards left.

Problem:

We have a chat application.
Allowed operations are:
1> Adding a person to chat group, format +priyanka
2> Removing a person to chat group, format -sonali
3> Sending a message to chat group, format priyanka:Hi
Now, no traffic is sent to server for adding or removing person. But for every
sent message, K bytes(length of message) for each person present in group are
sent to server. Like if only Priyanka is there is a group, then Priyanka:Hello
will send 5 bytes. If 2 persons are there in group, Priyanka:Hello will send
5x2=10 bytes.
Find total bytes sent to server.
Note: All input data is correct. A person cannot be added if it is already
there in group. A person cannot be removed if he/she is not there is group. No
two persons have same name.

There is a list of N students with their first names. Now if 2 or more students have same name, you need to change 2nd name to "name1", 3rd name to "name2" and so on. If there is only 1 occurrence of particular name, then it will remain as it is.

Input Format:

N(number of students)N lines with 1 name each

Output Format:n lines with modified names

Constraints:None

Sample Input

10priyasatyamshikhasidamitshikhaamitamitamitsatyam

Sample Output:priyasatyamshikhasidamitshikha1amit1amit2amit3satyam1

Explanations:
As soon as name "shikha" came for 2nd time, change it to "shikha1" and so on.

In a chess board, only 1 King is left. Given his current position and his destination position, find number of minimum moves, in which king can reach his destinations.Valid moves are same as that of King in Chess Game.

Input Format:

T(number of test cases)

Next T lines having initial position and destination position like a1 d7

26 November 2014

Few friends are playing cards. There play N rounds. Winner of each round is in format "name points". Points of all other players for that round is 0. Final Winner is the person with maximum total points of all rounds. It is guaranteed that no 2 players will have same maximum total after N rounds. Find the name of person and his/her total score

Given a rectangular ground of dimension X by Y. And we have square tiles of size A by A. Find minimum number of tiles required to cover the ground.Note: Tiles cannot be broken, it is OK if titles crosses rectangle boundary.

Input Format:

X Y A

Output Format:Number of tiles

Constraints:None

Sample Input

8 10 4

Sample Output:6

Explanations:
8 x 8 will be covered by 4 titles of 4 x 4. Remaining area 8 x 2 will be covered by another 2 tiles. So total 6 tiles.

15 November 2014

Given T number, you have to select N numbers such that Max(Selection)-Min(Selection) is minimum. Print Max(Selection)-Min(Selection)ex: if T=3 and N=2 and numbers are 1,2,4 , then selection can be (1,2) or(2,4) or (1,4).max(1,2)-min(1,2)=2-1=1max(2,4)-min(2,4)=4-2=2max(1,4)-min(1,4)=4-1=3Clearly 1 is minimum, so output should be 1.

Input Format:

Total number TSubset number Nnext T lines having numbers

Output Format:Max(Selection)-Min(Selection)

Constraints:none

Sample Input

7326101241116

Sample Output:2

Explanations:
We have to select 3 numbers from 7 numbers- 2,6,10,12,4,11,16.
We should select 10,11,12. Max(10,11,12)=12. Min(10,11,12)=10. Diff=2. All other possible combinations have difference more than 2.

Given a string, you need to convert to a different string such that consecutive characters should be different. Only operation allowed is to delete any alphabet of string. Find minimum number of deletion required

Input Format:

number of test cases Tnext T lines contains a string to be tested

Output Format:Minimum number of deletion required

Constraints:none

Sample Input

3ababaaaaabbbbacbbca

Sample Output:061

Explanations:
ababa already have proper condition.
aaaabbbb = ab, so 3 a and 3 b deleted, so ans is 3+3=6
acbbca = acbca, so only 1 b need to be deleted