Problem Statement
You are given a String[] board, where the jth character of the ith element represents the cell at row i, column j. A '.' denotes an empty cell, and a '#' denotes a destroyed cell. A solution is represented by a string which concatenates the positions of the queens. Each queen will be represented by two characters rc, where r is the row label and c is the column label. For example, if the solution contains one queen at row 1, column H and another at row 5, column C, it can be represented as "1H5C" or "5C1H". If there are several solutions which use the minimal number of queens, return the one that comes first lexicographically.
Definition
- Class:
- QueenCovering
- Method:
- getPlacement
- Parameters:
- String[]
- Returns:
- String
- Method signature:
- String getPlacement(String[] board)
- (be sure your method is public)
Constraints
- board will have exactly 8 elements.
- Each element of board will contain exactly 8 characters.
- Each character of board will be either '.' or '#'.
Examples
{ "........", "..######", ".#.#####", ".##.####", ".###.###", ".####.##", ".#####.#", "........"}Returns: "1A8B"
We place one queen on the first row and the first column, and another queen on the last row and on the second column.{ "#......#", ".#......", "..#...#.", "........", "..#.....", "..#..#..", "#.......", "#...###."}Returns: "1B2D3A4C5E"
{ "........", "........", "........", "........", "........", "........", "........", "........"}Returns: "1A2C3E4B5D"
{ "..##.##.", ".###..##", "##..###.", "#..#...#", ".#.##.#.", "#...##..", "#..#####", "..#..#.#"}Returns: "1A4C5H6B"
{ "########", "########", "########", "########", "########", "########", "########", "########" }Returns: ""