Assign numbers 1 to 26 to letters by scanning the grid and numbering each letter at its first appearance.
Easy2SimulationStringImplementationInterviewNo attempts yetTime limit2sMemory limit512 MBAn alpha puzzle is a crossword variant in which every letter square (that is, every square that is not black) holds a number instead of a letter. The same letter is always represented by the same number across the whole puzzle, and all 26 letters of the alphabet are used, so the numbers run from 1 to 26.
You are given a solved alpha puzzle and have to work out which number belongs to which letter. Some alpha puzzles assign the numbers at random, but the one printed every day in the New Zealand Herald uses a fixed method, and that method is the one to implement here.
Read the answer grid left to right, top to bottom, and skip the spaces that stand for black squares. The first letter you meet is assigned the number 1, the next letter that has not appeared yet is assigned 2, and so on. Only the first occurrence of a letter is processed, so exactly 26 numbers are handed out.
The first line contains one integer S, the size of the puzzle, which is both the number of rows and the number of columns (10≤S≤20).
Each of the next S lines holds one row of the grid and consists of upper case letters and spaces. Trailing spaces in a row may have been removed, so a line can be shorter than S characters or even empty. Every letter of the alphabet appears at least once in the grid.
Print the 26 letters of the alphabet on one line, in the order of the numbers assigned to them. The first letter printed is the one assigned 1 and the last is the one assigned 26.