当前位置:网站首页>Leetcode 2194. Excel 錶中某個範圍內的單元格(可以,已解决)
Leetcode 2194. Excel 錶中某個範圍內的單元格(可以,已解决)
2022-06-12 16:30:00 【我不是蕭海哇~~~~】

Excel 錶中的一個單元格 (r, c) 會以字符串 “” 的形式進行錶示,其中:
- 即單元格的列號 c 。用英文字母錶中的 字母 標識。 例如,第 1 列用 'A' 錶示,第 2 列用 'B' 錶示,第 3 列用 'C' 錶示,以此類推。
- 即單元格的行號 r 。第 r 行就用 整數 r 標識。
給你一個格式為 “:” 的字符串 s ,其中 錶示 c1 列, 錶示 r1 行, 錶示 c2 列, 錶示 r2 行,並滿足 r1 <= r2 且 c1 <= c2 。
找出所有滿足 r1 <= x <= r2 且 c1 <= y <= c2 的單元格,並以列錶形式返回。單元格應該按前面描述的格式用 字符串 錶示,並以 非遞减 順序排列(先按列排,再按行排)。
示例 1:

輸入:s = "K1:L2"
輸出:["K1","K2","L1","L2"]
解釋:
上圖顯示了列錶中應該出現的單元格。
紅色箭頭指示單元格的出現順序。
示例 2:

輸入:s = "A1:F1"
輸出:["A1","B1","C1","D1","E1","F1"]
解釋:
上圖顯示了列錶中應該出現的單元格。
紅色箭頭指示單元格的出現順序。
提示:
- s.length == 5
- ‘A’ <= s[0] <= s[3] <= ‘Z’
- ‘1’ <= s[1] <= s[4] <= ‘9’
- s 由大寫英文字母、數字、和 ‘:’ 組成
Code:
class Solution {
public:
vector<string> cellsInRange(string s) {
int start=s[1]-'0';
int end=s[4]-'0';
vector<string>res;
for(int j=s[0];j<=s[3];j++)
{
string temp;
for(int i=start;i<=end;i++)
{
temp+=j;
temp+=to_string(i);
// cout<<temp<<endl;
res.push_back(temp);
temp="";
}
}
return res;
}
};
边栏推荐
- What's the matter with pbootcms' if judgment failure and direct display of labels?
- <山东大学项目实训>渲染引擎系统(二)
- Acwing 1927 自动补全(知识点:hash,二分,排序)
- 双写一致性问题
- 武汉大学甘菲课题组和南昌大学徐振江课题组联合招聘启事
- 大规模实时分位数计算——Quantile Sketches 简史
- 33-【go】Golang sync.WaitGroup的用法—保证go协程执行完毕,主协程才退出
- 【摸鱼神器】UI库秒变LowCode工具——列表篇(一)设计与实现
- Joint recruitment notice of ganfei research group of Wuhan University and xuzhenjiang research group of Nanchang University
- MongoDB系列之SQL和NoSQL的区别
猜你喜欢

关于组件传值

大规模实时分位数计算——Quantile Sketches 简史

Recurrent+Transformer 视频恢复领域的‘德艺双馨’

How to base on CCS_ V11 new tms320f28035 project

Super detailed dry goods! Docker+pxc+haproxy build a MySQL Cluster with high availability and strong consistency

Super detailed dry goods! Docker+pxc+haproxy build a MySQL Cluster with high availability and strong consistency

The market share of packaged drinking water has been the first for eight consecutive years. How does this brand DTC continue to grow?

Kill program errors in the cradle with spotbugs

批量--03---CmdUtil

MySQL - server configuration related problems
随机推荐
h t fad fdads
<山东大学项目实训>渲染引擎系统(二)
leetcode-54. Spiral matrix JS
acwing795 前缀和(一维)
acwing 803. Interval merging
Servlet API
Interview: difference between '= =' and equals()
深入理解 Go Modules 的 go.mod 与 go.sum
统计机器学习代码合集
数据库的三大范式
Project training of Shandong University rendering engine system (III)
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.7 实例(存储分配程序)
The C programming language (version 2) notes / 8 UNIX system interface / 8.1 file descriptor
MySQL面试整理
acwing796 子矩阵的和
acwing 798二维差分(差分矩阵)
acwing 790. The cubic root of a number (floating-point number in half)
Postgresql源码(53)plpgsql语法解析关键流程、函数分析
Acwing794 high precision Division
超详细干货!Docker+PXC+Haproxy搭建高可用强一致性的MySQL集群