Spreadsheet
SRM 839 · 2022-09-30 · by misof
SRM 839 · 2022-09-30 · by misof · Simple Math, Simple Search, Iteration, String Manipulation
Problem Statement
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
Return the label of the column that is immediately to the right of the given column.
Constraints
- column will contain between 1 and 10 characters, inclusive.
- Each character of column will be an uppercase English letter ('A'-'Z').
Examples
0)
"SRM" Returns: "SRN"
1)
"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".
2)
"TOPCODER" Returns: "TOPCODES"
3)
"WALTZ" Returns: "WALUA"
4)
"BUZZZ" Returns: "BVAAA"
Submissions are judged against all 12 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class Spreadsheet with a public method string goRight(string column) · 12 test cases · 2 s / 256 MB per case