<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>table Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/table/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/table/</link>
	<description></description>
	<lastBuildDate>Tue, 08 Mar 2022 11:06:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>table Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/table/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 2194. Cells in a Range on an Excel Sheet</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-2194-cells-in-a-range-on-an-excel-sheet/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-2194-cells-in-a-range-on-an-excel-sheet/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Tue, 08 Mar 2022 11:05:29 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[table]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=9547</guid>

					<description><![CDATA[<p>A cell&#160;(r, c)&#160;of an excel sheet is represented as a string&#160;"&#60;col&#62;&#60;row&#62;"&#160;where: &#60;col&#62;&#160;denotes the column number&#160;c&#160;of the cell. It is represented by&#160;alphabetical letters. For example, the&#160;1st&#160;column&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-2194-cells-in-a-range-on-an-excel-sheet/">花花酱 LeetCode 2194. Cells in a Range on an Excel Sheet</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A cell&nbsp;<code>(r, c)</code>&nbsp;of an excel sheet is represented as a string&nbsp;<code>"&lt;col&gt;&lt;row&gt;"</code>&nbsp;where:</p>



<ul><li><code>&lt;col&gt;</code>&nbsp;denotes the column number&nbsp;<code>c</code>&nbsp;of the cell. It is represented by&nbsp;<strong>alphabetical letters</strong>.<ul><li>For example, the&nbsp;<code>1<sup>st</sup></code>&nbsp;column is denoted by&nbsp;<code>'A'</code>, the&nbsp;<code>2<sup>nd</sup></code>&nbsp;by&nbsp;<code>'B'</code>, the&nbsp;<code>3<sup>rd</sup></code>&nbsp;by&nbsp;<code>'C'</code>, and so on.</li></ul></li><li><code>&lt;row&gt;</code>&nbsp;is the row number&nbsp;<code>r</code>&nbsp;of the cell. The&nbsp;<code>r<sup>th</sup></code>&nbsp;row is represented by the&nbsp;<strong>integer</strong>&nbsp;<code>r</code>.</li></ul>



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



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



<p><strong>Example 1:</strong></p>



<figure class="wp-block-image"><img src="https://assets.leetcode.com/uploads/2022/02/08/ex1drawio.png" alt=""/></figure>



<pre class="wp-block-preformatted;crayon:false"><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>



<figure class="wp-block-image"><img src="https://assets.leetcode.com/uploads/2022/02/09/exam2drawio.png" alt=""/></figure>



<pre class="wp-block-preformatted;crayon:false"><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><strong>Constraints:</strong></p>



<ul><li><code>s.length == 5</code></li><li><code>'A' &lt;= s[0] &lt;= s[3] &lt;= 'Z'</code></li><li><code>'1' &lt;= s[1] &lt;= s[4] &lt;= '9'</code></li><li><code>s</code>&nbsp;consists of uppercase English letters, digits and&nbsp;<code>':'</code>.</li></ul>



<h2><strong>Solution: Brute Force</strong></h2>



<p>Time complexity: O((row2 &#8211; row1 + 1) * (col2 &#8211; col1 + 1))<br>Space complexity: O(1)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  vector&lt;string&gt; cellsInRange(string s) {
    vector&lt;string&gt; ans;
    for (char c = s[0]; c &lt;= s[3]; ++c)
      for (char r = s[1]; r &lt;= s[4]; ++r)        
        ans.push_back(string{c, r});
    return ans;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-2194-cells-in-a-range-on-an-excel-sheet/">花花酱 LeetCode 2194. Cells in a Range on an Excel Sheet</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/string/leetcode-2194-cells-in-a-range-on-an-excel-sheet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
