当前位置:网站首页>Leetcode 2194. Cells within a range in Excel table (yes, solved)
Leetcode 2194. Cells within a range in Excel table (yes, solved)
2022-06-12 16:31:00 【I'm not xiaohaiwa~~~~】

Excel A cell in a table (r, c) String “” In the form of , among :
- That is, the column number of the cell c . Use... In the English alphabet Letter identification . for example , The first 1 Column use 'A' Express , The first 2 Column use 'B' Express , The first 3 Column use 'C' Express , And so on .
- That is, the row number of the cell r . The first r Just use it Integers r identification .
Give you a format of “:” String s , among Express c1 Column , Express r1 That's ok , Express c2 Column , Express r2 That's ok , And satisfy r1 <= r2 And c1 <= c2 .
Find all the satisfaction r1 <= x <= r2 And c1 <= y <= c2 Cells of , And return... As a list . Cells should be in the format described above character string Express , And The decreasing Sequential arrangement ( First by column , Then line up ).
Example 1:

Input :s = "K1:L2"
Output :["K1","K2","L1","L2"]
explain :
The above figure shows the cells that should appear in the list .
Red arrows indicate the order in which cells appear .
Example 2:

Input :s = "A1:F1"
Output :["A1","B1","C1","D1","E1","F1"]
explain :
The above figure shows the cells that should appear in the list .
Red arrows indicate the order in which cells appear .
Tips :
- s.length == 5
- ‘A’ <= s[0] <= s[3] <= ‘Z’
- ‘1’ <= s[1] <= s[4] <= ‘9’
- s It consists of capital letters 、 Numbers 、 and ‘:’ form
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;
}
};
边栏推荐
- Acwing high precision multiplication
- Browsercontext class of puppeter
- 深入理解 Go Modules 的 go.mod 与 go.sum
- Acwing795 prefix sum (one dimension)
- Multimix: small amount of supervision from medical images, interpretable multi task learning
- CAS乐观锁
- use. Net upgrade assistant upgrades the net core 3.1 project to NET 6
- [BSP video tutorial] BSP video tutorial issue 17: single chip microcomputer bootloader topic, startup, jump configuration and various usage of debugging and downloading (2022-06-10)
- Batch --03---cmdutil
- QCustomplot笔记(一)之QCustomplot添加数据以及曲线
猜你喜欢

统计机器学习代码合集

关于组件传值

Acwing 798 two dimensional difference (difference matrix)

acwing 803. 区间合并

Servlet API

Kill program errors in the cradle with spotbugs

Acwing 797 differential

The process of "unmanned aquaculture"

Project training of Shandong University rendering engine system (III)

Gopher to rust hot eye grammar ranking
随机推荐
The C programming language (version 2) notes / 8 UNIX system interface / 8.2 low level i/o (read and write)
《安富莱嵌入式周报》第268期:2022.05.30--2022.06.05
34-【go】Golang channel知识点
acwing 800. Target and of array elements
双写一致性问题
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.7 实例(存储分配程序)
Multimix: small amount of supervision from medical images, interpretable multi task learning
Interview: do you understand the packing and unpacking operations?
Acwing high precision multiplication
武汉大学甘菲课题组和南昌大学徐振江课题组联合招聘启事
Postgresql源码(53)plpgsql语法解析关键流程、函数分析
acwing 高精度乘法
5-5 configuring MySQL replication log point based replication
h t fad fdads
Interview: what are shallow copy and deep copy?
你的下一台电脑何必是电脑,探索不一样的远程操作
QCustomplot笔记(一)之QCustomplot添加数据以及曲线
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.5 实例(fopen 和 getc 函数的实现)
Cookie 和 Session
批量--03---CmdUtil