当前位置:网站首页>2309. The best English letters with both upper and lower case
2309. The best English letters with both upper and lower case
2022-07-05 09:06:00 【Laver (nori)】
Ideas :
1. Use fixed length arrays , Store whether upper and lower case letters appear ;
2. Reverse traversal , Start with the big letters , Until you find the result ;
class Solution {
public:
string greatestLetter(string s) {
// A lowercase letter
vector<int> auxUpper(26, 0);
// Capitalization
vector<int> auxLower(26, 0);
// Traversal string s, Record the upper and lower case letters
for(auto ch : s){
if(ch >= 'A' && ch <= 'Z'){
// upper letter
auxUpper[(int)(ch - 'A')] = 1;
}else{
// lower letter
auxLower[(int)(ch - 'a')] = 1;
}
}
// Traverse in reverse order to find the first letter with both upper and lower case
for(int i = 25; i >= 0; i--){
if(auxUpper[i] == 1 && auxLower[i] == 1){
return string(1, (char)(i + 'A'));
}
}
return "";
}
};
边栏推荐
- Halcon: check of blob analysis_ Blister capsule detection
- [daiy4] jz32 print binary tree from top to bottom
- 资源变现小程序添加折扣充值和折扣影票插件
- Array, date, string object method
- C#绘制带控制点的Bezier曲线,用于点阵图像及矢量图形
- OpenFeign
- Huber Loss
- kubeadm系列-01-preflight究竟有多少check
- 浅谈Label Smoothing技术
- Golang foundation -- map, array and slice store different types of data
猜你喜欢
Summary of "reversal" problem in challenge Programming Competition
RT thread kernel quick start, kernel implementation and application development learning with notes
Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
Attention is all you need
信息与熵,你想知道的都在这里了
Halcon color recognition_ fuses. hdev:classify fuses by color
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Blogger article navigation (classified, real-time update, permanent top)
随机推荐
Transfer learning and domain adaptation
C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
Ecmascript6 introduction and environment construction
2311. 小于等于 K 的最长二进制子序列
信息與熵,你想知道的都在這裏了
[daiy4] jz32 print binary tree from top to bottom
2011-11-21 training record personal training (III)
特征工程
Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
AdaBoost use
JS asynchronous error handling
Jenkins pipeline method (function) definition and call
太不好用了,长文章加图文,今后只写小短文
How many checks does kubedm series-01-preflight have
scipy. misc. imread()
Pearson correlation coefficient
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
Huber Loss
Rebuild my 3D world [open source] [serialization-1]
Codeforces Round #648 (Div. 2) D. Solve The Maze