Statistics

Problem Statement for "SpreadsheetColumn"

Problem Statement

Many spreadsheet applications use positive integers to label rows of cells and strings to label columns of cells. Your task is to write a function that gets the number of the column and returns its label.

All 26 uppercase letters are used to label the columns. Column labels are ordered according to their length, and labels with the same length are ordered in alphabetical order. Thus, the first 26 columns have a one-letter label, the following 26*26 columns have a two-letter label. The sequence of the labels looks as follows:

A, B, C, ..., Z, AA, AB, ..., AZ, BA, BB, ..., ZY, ZZ

The columns are numbered from 1, i.e., column number 1 has the label A.

Definition

Class:
SpreadsheetColumn
Method:
getLabel
Parameters:
int
Returns:
String
Method signature:
String getLabel(int column)
(be sure your method is public)

Notes

  • The constraints will guarantee that the column label is between "A" and "ZZ", inclusive

Constraints

  • column will be between 1 and 702, inclusive.

Examples

  1. 1

    Returns: "A"

  2. 2

    Returns: "B"

  3. 27

    Returns: "AA"

  4. 111

    Returns: "DG"

  5. 702

    Returns: "ZZ"

    Note that this is the largest possible input.

  6. 3

    Returns: "C"

  7. 4

    Returns: "D"

  8. 5

    Returns: "E"

  9. 6

    Returns: "F"

  10. 7

    Returns: "G"

  11. 8

    Returns: "H"

  12. 9

    Returns: "I"

  13. 10

    Returns: "J"

  14. 11

    Returns: "K"

  15. 12

    Returns: "L"

  16. 13

    Returns: "M"

  17. 14

    Returns: "N"

  18. 15

    Returns: "O"

  19. 16

    Returns: "P"

  20. 17

    Returns: "Q"

  21. 18

    Returns: "R"

  22. 19

    Returns: "S"

  23. 20

    Returns: "T"

  24. 21

    Returns: "U"

  25. 22

    Returns: "V"

  26. 23

    Returns: "W"

  27. 24

    Returns: "X"

  28. 25

    Returns: "Y"

  29. 26

    Returns: "Z"

  30. 27

    Returns: "AA"

  31. 28

    Returns: "AB"

  32. 29

    Returns: "AC"

  33. 30

    Returns: "AD"

  34. 31

    Returns: "AE"

  35. 41

    Returns: "AO"

  36. 42

    Returns: "AP"

  37. 43

    Returns: "AQ"

  38. 44

    Returns: "AR"

  39. 47

    Returns: "AU"

  40. 48

    Returns: "AV"

  41. 49

    Returns: "AW"

  42. 50

    Returns: "AX"

  43. 51

    Returns: "AY"

  44. 52

    Returns: "AZ"

  45. 53

    Returns: "BA"

  46. 54

    Returns: "BB"

  47. 55

    Returns: "BC"

  48. 56

    Returns: "BD"

  49. 63

    Returns: "BK"

  50. 73

    Returns: "BU"

  51. 83

    Returns: "CE"

  52. 93

    Returns: "CO"

  53. 103

    Returns: "CY"

  54. 203

    Returns: "GU"

  55. 303

    Returns: "KQ"

  56. 403

    Returns: "OM"

  57. 503

    Returns: "SI"

  58. 697

    Returns: "ZU"

  59. 698

    Returns: "ZV"

  60. 699

    Returns: "ZW"

  61. 700

    Returns: "ZX"

  62. 701

    Returns: "ZY"

  63. 53

    Returns: "BA"

  64. 702

    Returns: "ZZ"

  65. 26

    Returns: "Z"

  66. 111

    Returns: "DG"

  67. 3

    Returns: "C"

  68. 676

    Returns: "YZ"

  69. 52

    Returns: "AZ"

  70. 78

    Returns: "BZ"

  71. 24

    Returns: "X"

  72. 25

    Returns: "Y"

  73. 2

    Returns: "B"

  74. 700

    Returns: "ZX"

  75. 5

    Returns: "E"

  76. 12

    Returns: "L"

  77. 53

    Returns: "BA"

  78. 702

    Returns: "ZZ"

  79. 26

    Returns: "Z"

  80. 111

    Returns: "DG"

  81. 3

    Returns: "C"

  82. 676

    Returns: "YZ"

  83. 52

    Returns: "AZ"

  84. 78

    Returns: "BZ"

  85. 24

    Returns: "X"

  86. 25

    Returns: "Y"

  87. 2

    Returns: "B"

  88. 700

    Returns: "ZX"

  89. 5

    Returns: "E"

  90. 12

    Returns: "L"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: