当前位置:网站首页>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 "";
}
};边栏推荐
- golang 基础 ——map、数组、切片 存放不同类型的数据
- Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
- 深入浅出PyTorch中的nn.CrossEntropyLoss
- notepad++
- Confusion matrix
- Codeworks round 639 (Div. 2) cute new problem solution
- Ministry of transport and Ministry of Education: widely carry out water traffic safety publicity and drowning prevention safety reminders
- File server migration scheme of a company
- Programming implementation of ROS learning 5-client node
- nodejs_ 01_ fs. readFile
猜你喜欢

我从技术到产品经理的几点体会
![Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]](/img/7d/e7370e757c18b3dbb47e633703c346.jpg)
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]

生成对抗网络

Programming implementation of ROS learning 6 -service node

IT冷知识(更新ing~)

Wechat H5 official account to get openid climbing account

Count of C # LINQ source code analysis
![Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]](/img/d8/39020b1ce174299f60b6f278ae0b91.jpg)
Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]

What is a firewall? Explanation of basic knowledge of firewall

Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
随机推荐
多元线性回归(sklearn法)
How many checks does kubedm series-01-preflight have
np.allclose
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
Programming implementation of subscriber node of ROS learning 3 subscriber
kubeadm系列-00-overview
深入浅出PyTorch中的nn.CrossEntropyLoss
Halcon shape_ trans
编辑器-vi、vim的使用
Ros-11 common visualization tools
Use arm neon operation to improve memory copy speed
Rebuild my 3D world [open source] [serialization-2]
微信H5公众号获取openid爬坑记
Golang foundation -- map, array and slice store different types of data
Redis implements a high-performance full-text search engine -- redisearch
Halcon affine transformations to regions
Driver's license physical examination hospital (114-2 hang up the corresponding hospital driver physical examination)
图解网络:什么是网关负载均衡协议GLBP?
Transfer learning and domain adaptation
Pearson correlation coefficient