Constellation
Given a matrix ‘UNIVERSE’ with 3 rows and ‘N’ columns, with the characters { # , * , . } and these characters represent a cluster of stars and galaxies in space. Stars are represented by ‘*’ symbol. The ‘.’ symbol represents empty space.
We define a constellation as a 3x3 matrix which contains stars in the shape of vowels. A group of constellations is defined as a galaxy. Note that a galaxy may contain many stars but they will never be overlapping. Two galaxies are separated by a column of ‘#’.
Given the ‘UNIVERSE’ matrix, print a string which denotes all the vowels formed by stars and ‘#’ present in the matrix.
A looks like this :
. * .
* * *
* . *
E looks like this :
* * *
* * *
* * *
I looks like this :
* * *
. * .
* * *
O looks like this :
* * *
* . *
* * *
U looks like this :
* . *
* . *
* * *
Note :
It is guaranteed that no two constellations are overlapping.
Input format :
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer ‘N’ denoting the number of columns in the matrix.
The next 3 lines of each test case denote the matrix of size 3 rows and ‘N’ columns which denotes the stars and the galaxies. Each line contains ‘N’ space separated characters from the set { ‘#’ , ’*’ , ’.’ }.
Output format :
For each test case, print a string which contains the shape of vowels and the hashes.
Note :
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 50
3 <= N <= 10^5
Time Limit : 1 sec
CodingNinjas
author
2y
Recursive Approach
The key idea is to recursively check every 3x3 grid and see what vowel does it signify and it to the string. This can be easily done using a recursive function.
Here is the algorithm...read more
CodingNinjas
author
2y
Iterative Approach
The key idea is to just check every 3x3 grid and see what vowel does it signify and it to the string. This can be easily done iterating through the matrix with the help of a loop.
He...read more
brucewayne
14d
works at
This can be solved by group islands
fearlessbrodo
1y
works at
nevknv
HARSH BEHL
2y
works at
test hailel how how doos s
Add answer anonymously...
Top TCS Assistant System Engineer interview questions & answers
Popular interview questions of Assistant System Engineer
Top HR questions asked in TCS Assistant System Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app