当前位置:网站首页>Leetcode 2194. Cellules dans une plage dans un tableau Excel (OK, résolu)
Leetcode 2194. Cellules dans une plage dans un tableau Excel (OK, résolu)
2022-06-12 16:31:00 【Je ne suis pas xiaohai.】

Excel Une cellule dans le tableau (r, c) Sera une chaîne “” Sous la forme de,Parmi eux:
- Est le numéro de colonne de la cellule c .Dans l'Alphabet anglais Lettres Identification. Par exemple,No 1 Colonne 'A' Représentation,No 2 Colonne 'B' Représentation,No 3 Colonne 'C' Représentation,Et ainsi de suite..
- Est le numéro de ligne de la cellule r .No r C'est bon. Entier r Identification.
Pour vous donner un format “:” La chaîne de s ,Parmi eux Représentation c1 Colonnes, Représentation r1 D'accord, Représentation c2 Colonnes, Représentation r2 D'accord,Et satisfait r1 <= r2 Et c1 <= c2 .
Trouver toutes les satisfactions r1 <= x <= r2 Et c1 <= y <= c2 Les cellules de,Et retourner sous forme de liste.Les cellules doivent être utilisées dans le format décrit précédemment. String Représentation,Et Non dégressif Ordre(Première colonne,En ligne.).
Exemple 1:

Entrée:s = "K1:L2"
Produits:["K1","K2","L1","L2"]
Explication:
La figure ci - dessus montre les cellules qui devraient apparaître dans la Liste.
Les flèches rouges indiquent l'ordre dans lequel les cellules apparaissent.
Exemple 2:

Entrée:s = "A1:F1"
Produits:["A1","B1","C1","D1","E1","F1"]
Explication:
La figure ci - dessus montre les cellules qui devraient apparaître dans la Liste.
Les flèches rouges indiquent l'ordre dans lequel les cellules apparaissent.
Conseils:
- s.length == 5
- ‘A’ <= s[0] <= s[3] <= ‘Z’
- ‘1’ <= s[1] <= s[4] <= ‘9’
- s En majuscules 、Nombre、Et ‘:’ Composition
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 800. Target and of array elements
- The C Programming Language(第 2 版) 笔记 / 7 输入与输出 / 7.8 其它函数
- The process of "unmanned aquaculture"
- calibration of sth
- The market share of packaged drinking water has been the first for eight consecutive years. How does this brand DTC continue to grow?
- How to construct PostgreSQL error codes
- 双写一致性问题
- MYSQL---服务器配置相关问题
- Thinking about the probability of drawing cards in the duel link of game king
猜你喜欢
随机推荐
Differences between SQL and NoSQL of mongodb series
【DSP视频教程】DSP视频教程第8期:DSP库三角函数,C库三角函数和硬件三角函数的性能比较,以及与Matlab的精度比较(2022-06-04)
Understand go modules' go Mod and go sum
面试:hashCode()和equals()
Sum of acwing796 submatrix
Super detailed dry goods! Docker+pxc+haproxy build a MySQL Cluster with high availability and strong consistency
试用期、加班补偿———进厂前后需要了解的知识《劳动法》
深入理解 Go Modules 的 go.mod 與 go.sum
【摸鱼神器】UI库秒变LowCode工具——列表篇(一)设计与实现
Postgresql源码(53)plpgsql语法解析关键流程、函数分析
Statistical machine learning code set
34-【go】Golang channel知识点
RTOS RT thread bare metal system and multi thread system
calibration of sth
acwing795 前缀和(一维)
acwing 803. 区间合并
Thread pool execution process
Page class of puppeter
Acwing high precision multiplication
Probation period and overtime compensation -- knowledge before and after entering the factory labor law









