In one of her adventures, Lara Croft comes across a maze floating in the sky filled withancient relics. She has a teleporter with her
which will help her to land on the maze from the ground and get back to the ground aftercollecting the relics. There are a couple of
catches though:
Complete the findMaximumRelics function ir the editor below. It has 1 parameter: grid: An array of strings. The cells of which
contain either '*' (denoting that the tile hasrelic) or ' (denoting that the tile has an obstacle).
Locked stub code in the editor reads the following input from stdin and passes it to the function:
The first line contains an integer, r, denoting the number of rows of the 2D grid. Then there are r lines . The ith lines contains a string denoting the configuration of the ith row of the grid . Each character in the string is either a "*"(denoting that the title has a relic) or '.'
(Denoting that the title has an obstacle)
is printed to stdout by locked stub code in the editor.
Sample Input 0
2
-*
*-
Sample Output 0
1
The grid has 2 rows and 2 columns. If Lara starts from the upper right tile she can only visit 1 tile and if she starts from bottom left tile she can again visit tile 1. So the maximum number of tiles she can visit is 1 (which is equal to the relics she an collect)
Relay race is a team sport where a baton ispassed from one person to another and eachperson is required to complete their racecourse with the baton and pass it to the next
person. We identify difference racers of ateam with their jersey colors.In this problem, you are given a list of transitions of the baton between different
people (identified by colors of their jerseys) and you are required to find the entire course of transition of the baton between two racers for multiple queries.
More formally you will be given a list of transistion of the form <colour1><colour2> reprsenting thata baton was passed between a racer wearing colour 1 jersey and racer in colour 2 jersey . You will be asked some queries of the format
1. A string array, transitions, which contains the number
of transitions that occurred in the relay race
2. A string array, queries which contains the
queries to be evaluated.
The function must return a string array which the answer to the query array. Each string in the array should be of the format ai,ai+1...an, where a is the color of the starting racer and aj-ri-2.. are the colors of the intermediate racers and an is the color
of the racer that finally has the baton. The number of steps to transition the baton from ai to an should be minimum possible.
Locked stub code in the editor reads the following input from stdin and passes it to the function: The first line contains an integer, n, denoting the
number of transitions. The next n lines contain the transitions. The line after that contains an integer, m, denoting the number of queries. The next m lines contain queries.
1<= n <= 55
1 <= m <= 3000
The function must return a string array as stated above in the problem description. This is printed to stdout by locked stub code in the editor
Sample Input 0
2
Red-Purple
Purple-Brown
1
Red-Brown
Sample Output 0
Red, Purple, Brown
Explanation 0
The transitions are Red-Purple and Purple-
Brown. The query is Red-Brown. The only way for transistions from
Red to Brown is Red,Purple,Brown. So this is the answer