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.
. * .
* * *
* . *
E looks like this :
* * *
* * *
* * *
I looks like this :
* * *
. * .
* * *
O looks like this :
* * *
* . *
* * *
U looks like this :
* . *
* . *
* * *
It is guaranteed that no two constellations are overlapping.
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 { ‘#’ , ’*’ , ’.’ }.
For each test case, print a string which contains the shape of vowels and the hashes.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
3 <= N <= 10^5
Time Limit: 1 sec
2
12
* . * # * * * # * * * #
* . * # * . * # . * . #
* * * # * * * # * * * #
7
* * * # * * *
* * * # * . *
* * * # * * *
U#O#I#
E#O
For the first test case,

We can clearly make out the blue U O I and E the A is in red to differentiate from E.
For the second test case,

We can clearly see the E and O in blue
2
11
* * * # * * * # * . *
* * * # . * . # * . *
* * * # * * * # * * *
3
* * *
* . *
* * *
E#I#U
O
Check alphabet in every 3x3 grid recursively.
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 :
O(N), where ‘N’ denotes the number of columns in the matrix.
We need to traverse each column once hence the overall time complexity will be O(N).
O(N), Where ‘N’ denotes the number of columns in the matrix.
Recursive stack uses space of order of ‘N’. Therefore, the overall space complexity will be O(N).