Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    2194 - Cells in a Range on an Excel Sheet.

    Easy

    A cell (r, c) of an excel sheet is represented as a string "<col><row>" where:

    • <col> denotes the column number c of the cell. It is represented by alphabetical letters.

    • &lt;row&gt; is the row number r of the cell. The <code>r<sup>th</sup></code> row is represented by the integer r.

    You are given a string s in the format "&lt;col1&gt;&lt;row1&gt;:&lt;col2&gt;&lt;row2&gt;", where &lt;col1&gt; represents the column c1, &lt;row1&gt; represents the row r1, &lt;col2&gt; represents the column c2, and &lt;row2&gt; represents the row r2, such that r1 &lt;= r2 and c1 &lt;= c2.

    Return the list of cells (x, y) such that r1 &lt;= x &lt;= r2 and c1 &lt;= y &lt;= c2. The cells should be represented as strings in the format mentioned above and be sorted in non-decreasing order first by columns and then by rows.

    Example 1:

    Input: s = "K1:L2"

    Output: "K1","K2","L1","L2"

    Explanation:

    The above diagram shows the cells which should be present in the list.

    The red arrows denote the order in which the cells should be presented.

    Example 2:

    Input: s = "A1:F1"

    Output: "A1","B1","C1","D1","E1","F1"

    Explanation:

    The above diagram shows the cells which should be present in the list.

    The red arrow denotes the order in which the cells should be presented.

    Constraints:

    • s.length == 5

    • 'A' &lt;= s[0] &lt;= s[3] &lt;= 'Z'

    • '1' &lt;= s[1] &lt;= s[4] &lt;= '9'

    • s consists of uppercase English letters, digits and ':'.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final List<String> cellsInRange(String s)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait