Sunday, July 30, 2017

Total Dribble Paths

A football coach wants his team to improve their dribbling skills. So he sets up a R * C grid, where R is the number of rows and C is the number of columns. From any given cell, a player can only dribble to the right cell or bottom cell. A player always starts from top left most cell and must end at bottom right most cell where he can collect the reward if he has dribbled according to the rules above. ...
Share:

Wednesday, July 26, 2017

Left Greater Number

Given an array of N positive integers, for each number print the first number to it’s left which is greater than the current number. Print -1 if there is no greater number on it's left. Input Format: The first line contains N. The second line contains N space separated positive integers. Output Format: N integers which represent the left greater numbers separated by a space. Boundary...
Share:

Tuesday, July 25, 2017

2D Matrix - Elements Adjacent Sum

Given a matrix of R rows and C columns, for each element print the sum of the adjacent elements. Input Format: The first line contains R The second line contains C Next R lines each contains C values separated by a space Output Format: R lines each containing C values which represent the sum of the adjacent elements. Boundary Conditions: 2 <= R,C <= 50 1 <= Matrix Elements...
Share:

Monday, July 24, 2017

Rhombus Pattern - N Slashes Side

Given an odd value of N, the program must print a rhombus in diamond shape whose side contains N slashes as shown below in the examples. Input Format: The first line contains N. Output Format: The rhombus in diamond shape with each side containing N slashes. Asterisk is used as a filler for other values. Boundary Conditions:1 <= N <= 101 and N is odd. Example Input/Output...
Share:

Sunday, July 23, 2017

King, Poet and Gold Coins

A king was happy with the skills of a poet and hence wanted to reward him. The king placed N boxes in a straight line each with certain number of gold coins - C(1) .... C(N) in it. The poet can pick any number of boxes but if the poet selected any box, then he should not pick the boxes which are adjacent to it (either to it's left or right). The poet also cannot rearrange the boxes. Given N and the...
Share:

Max Winning Streak Game Points

Alok is playing N round of card games with his friend Brinda. He gets postive or negative points based on whether he won or lost in a specific round. Alok can also get zero points in case of a tie. Given the points obtained in N rounds, the program must print the maximum sum of points obtained in any of the winning streak sequence. Input Format: The first line contains N. The second line contains...
Share:

Saturday, July 22, 2017

Numbers with unit Digit

Given two positive integers A and B and a digit U, the program must print all the integers from A to B (inclusive of A and B), which have their unit digit as U. Input Format: The first line contains A The second line contains B The third line contains U Output Format: The first line contains the integers from A to B having their unit digit as U in ascending order with each integer separated...
Share:

Wednesday, July 19, 2017

Unique count of Winners

Certain number of people play a card game. They play N rounds. The names of the winner in each round is passed as the input to the program. The program must print the unique count of the winners. Input Format: The first line contains the values of N. N lines contain the names of the winners. Output Format: The first line contains the unique count of winners. Boundary Conditions:...
Share:

Dog jumping barricade

Celine is training her dog to participate in a jumping show where the barricades height differs randomly. As the barricades are inclined, if the dog jumps X feet, it will be dragged down by Y feet due to its body weight until it balances and jumps again. Every day she trains her dogs to jump ‘N‘ such barricades. Help Celine by complete the program below which calculates the minimum number of jumps...
Share:

Sum of multiples of X between A and B

Given the values for X, A and B, the program must print the sum of multiples of X from A to B (inclusive of A and B). Input Format: The first line contains the value of X. The second line contains the value of A. The third line contains the value of B. Output Format: The first line contains the sum of multiples of X from A to B (inclusive of A and B). Boundary Conditions: 1 <=...
Share:

Students and Department

Given N students name and department, print the X students belonging to a specific department D. Input Format: The first line contains the values of N. N lines contain the name and department of N students separated by a space. The next line (N+2)th line, will contain the department name D for which the students list is to be printed. Output Format: X lines containing students name...
Share:

Numbers Range Count

Given N distinct integers, the program must print the number of ranges R present. A range is defined as two or more consecutive integers. Input Format: The first line contains N. The second line contains N integer values separated by a space. Output Format: The first line contains R. Boundary Conditions: 2 <= N <= 100000 1 <= R <= 10000 Example Input/Output 1:...
Share:

Sunday, July 2, 2017

Decode Ways

A top-secret message string S containing letters from A-Z (only upper-case letters) is encoded to numbers using the following mapping: 'A' -> 1, 'B' -> 2 and so on till Z -> '26' The program has to print the total number of ways in which the received message can be decoded. Input Format: The first line contains the string S containing numbers. Output Format: The first line contains the...
Share: