当前位置:网站首页>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;
}
};
边栏推荐
- 【BSP视频教程】BSP视频教程第17期:单片机bootloader专题,启动,跳转配置和调试下载的各种用法(2022-06-10)
- acwing 800. 数组元素的目标和
- acwing794 高精度除法
- 程序的动态加载和执行
- Acwing788. number of reverse order pairs
- vim 从嫌弃到依赖(16)——宏
- acwing 802. Interval sum (discretization)
- acwing 801. 二进制中1的个数(位运算)
- Project training of Shandong University rendering engine system (IV)
- generate pivot data 1
猜你喜欢
Statistical machine learning code set
Sum of acwing796 submatrix
Large scale real-time quantile calculation -- a brief history of quantitative sketches
[research] reading English papers -- the welfare of researchers in English poor
leetcode-54. Spiral matrix JS
超详细干货!Docker+PXC+Haproxy搭建高可用强一致性的MySQL集群
canvas 高级功能(下)
统计机器学习代码合集
acwing 790. The cubic root of a number (floating-point number in half)
Servlet API
随机推荐
acwing794 高精度除法
AssertJ 的异常(Exception )断言
Joint recruitment notice of ganfei research group of Wuhan University and xuzhenjiang research group of Nanchang University
Postgresql错误码是如何构造的
WebRTC 的音频网络对抗概述
acwing 2816. Judgement subsequence
canvas 高级功能(下)
【DSP视频教程】DSP视频教程第8期:DSP库三角函数,C库三角函数和硬件三角函数的性能比较,以及与Matlab的精度比较(2022-06-04)
Comprendre le go des modules go. MOD et go. SUM
Daily question -890 Find and replace mode
acwing 高精度乘法
token与幂等性问题
Super detailed dry goods! Docker+pxc+haproxy build a MySQL Cluster with high availability and strong consistency
批量--04---移动构件
Batch --04--- moving components
34-【go】Golang channel知识点
acwing 800. Target and of array elements
The C programming language (version 2) notes / 8 UNIX system interface / 8.5 instance (implementation of fopen and Getc functions)
HEMA is the best representative of future retail
VIM from dislike to dependence (16) -- macro