java.lang.Object
g2101_2200.s2194_cells_in_a_range_on_an_excel_sheet.Solution

public class Solution extends Object
2194 - Cells in a Range on an Excel Sheet.<p>Easy</p> <p>A cell <code>(r, c)</code> of an excel sheet is represented as a string <code>&quot;<col><row>&quot;</code> where:</p> <ul> <li><code><col></code> denotes the column number <code>c</code> of the cell. It is represented by <strong>alphabetical letters</strong>. <ul> <li>For example, the <code>1<sup>st</sup></code> column is denoted by <code>'A'</code>, the <code>2<sup>nd</sup></code> by <code>'B'</code>, the <code>3<sup>rd</sup></code> by <code>'C'</code>, and so on.</li> </ul> </li> <li><code><row></code> is the row number <code>r</code> of the cell. The <code>r<sup>th</sup></code> row is represented by the <strong>integer</strong> <code>r</code>.</li> </ul> <p>You are given a string <code>s</code> in the format <code>&quot;<col1><row1>:<col2><row2>&quot;</code>, where <code><col1></code> represents the column <code>c1</code>, <code><row1></code> represents the row <code>r1</code>, <code><col2></code> represents the column <code>c2</code>, and <code><row2></code> represents the row <code>r2</code>, such that <code>r1 <= r2</code> and <code>c1 <= c2</code>.</p> <p>Return <em>the <strong>list of cells</strong></em> <code>(x, y)</code> <em>such that</em> <code>r1 <= x <= r2</code> <em>and</em> <code>c1 <= y <= c2</code>. The cells should be represented as <strong>strings</strong> in the format mentioned above and be sorted in <strong>non-decreasing</strong> order first by columns and then by rows.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2022/02/08/ex1drawio.png" alt="" /></p> <p><strong>Input:</strong> s = &ldquo;K1:L2&rdquo;</p> <p><strong>Output:</strong> [&ldquo;K1&rdquo;,&ldquo;K2&rdquo;,&ldquo;L1&rdquo;,&ldquo;L2&rdquo;]</p> <p><strong>Explanation:</strong></p> <p>The above diagram shows the cells which should be present in the list.</p> <p>The red arrows denote the order in which the cells should be presented.</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2022/02/09/exam2drawio.png" alt="" /></p> <p><strong>Input:</strong> s = &ldquo;A1:F1&rdquo;</p> <p><strong>Output:</strong> [&ldquo;A1&rdquo;,&ldquo;B1&rdquo;,&ldquo;C1&rdquo;,&ldquo;D1&rdquo;,&ldquo;E1&rdquo;,&ldquo;F1&rdquo;]</p> <p><strong>Explanation:</strong></p> <p>The above diagram shows the cells which should be present in the list.</p> <p>The red arrow denotes the order in which the cells should be presented.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>s.length == 5</code></li> <li><code>'A' <= s[0] <= s[3] <= 'Z'</code></li> <li><code>'1' <= s[1] <= s[4] <= '9'</code></li> <li><code>s</code> consists of uppercase English letters, digits and <code>':'</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details