Problem Statement
In all modern spreadsheet apps the columns are labelled using strings of uppercase English letters. From the left to the right, the labels look as follows:
- First, there are all 26 possible 1-letter labels, in alphabetical order: "A", "B", "C", ..., "Y", "Z".
- Then, there are all 26^2 possible 2-letter labels, in alphabetical order: "AA", "AB", "AC", ..., "AY", "AZ", "BA", "BB", ..., "ZX", "ZY", "ZZ".
- Then, there are all 26^3 possible 3-letter labels, in alphabetical order: everything from "AAA" to "ZZZ".
- Afterwards, there are all possible labels with 4, 5, 6, ... letters.
You are given the String column: the label of a column in a spreadsheet.
Return the label of the column that is immediately to the right of the given column.
Definition
- Class:
- Spreadsheet
- Method:
- goRight
- Parameters:
- String
- Returns:
- String
- Method signature:
- String goRight(String column)
- (be sure your method is public)
Constraints
- column will contain between 1 and 10 characters, inclusive.
- Each character of column will be an uppercase English letter ('A'-'Z').
Examples
"SRM"
Returns: "SRN"
"Z"
Returns: "AA"
The column "Z" is the last column with a one-letter name. The next column is the first column with a two-letter name: "AA"."TOPCODER"
Returns: "TOPCODES"
"WALTZ"
Returns: "WALUA"