mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
47 lines
2.8 KiB
HTML
47 lines
2.8 KiB
HTML
<p>A cell <code>(r, c)</code> of an excel sheet is represented as a string <code>"<col><row>"</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>"<col1><row1>:<col2><row2>"</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> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
<img alt="" src="https://assets.leetcode.com/uploads/2022/02/08/ex1drawio.png" style="width: 250px; height: 160px;" />
|
|
<pre>
|
|
<strong>Input:</strong> s = "K1:L2"
|
|
<strong>Output:</strong> ["K1","K2","L1","L2"]
|
|
<strong>Explanation:</strong>
|
|
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.
|
|
</pre>
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
<img alt="" src="https://assets.leetcode.com/uploads/2022/02/09/exam2drawio.png" style="width: 500px; height: 50px;" />
|
|
<pre>
|
|
<strong>Input:</strong> s = "A1:F1"
|
|
<strong>Output:</strong> ["A1","B1","C1","D1","E1","F1"]
|
|
<strong>Explanation:</strong>
|
|
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.
|
|
</pre>
|
|
|
|
<p> </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>
|