Skip to content

Commit 03a9615

Browse files
committed
2309 added.
1 parent 6c37584 commit 03a9615

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
project(A)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
add_executable(A main.cpp)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// Source : https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/
2+
/// Author : liuyubobobo
3+
/// Time : 2022-06-21
4+
5+
#include <iostream>
6+
#include <vector>
7+
8+
using namespace std;
9+
10+
11+
/// Simulation
12+
/// Time Complexity: O(n)
13+
/// Space Complexity: O(1)
14+
class Solution {
15+
public:
16+
string greatestLetter(string s) {
17+
18+
vector<bool> upper(26, false), lower(26, false);
19+
for(char c: s){
20+
if(isupper(c)) upper[c - 'A'] = true;
21+
else lower[c - 'a'] = true;
22+
}
23+
24+
int res = -1;
25+
for(int i = 0; i < 26; i ++)
26+
if(upper[i] && lower[i]) res = i;
27+
return res == -1 ? "" : string(1, 'A' + res);
28+
}
29+
};
30+
31+
32+
int main() {
33+
34+
return 0;
35+
}

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,7 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
21542154
| 2306 | [Naming a Company](https://leetcode.com/problems/naming-a-company/) | [] | [C++](2001-2500/2306-Naming-a-Company/cpp-2306/) | | |
21552155
| | | | | | |
21562156
| 2308 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
2157+
| 2309 | [Greatest English Letter in Upper and Lower Case](https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/) | [] | [C++](2001-2500/2309-Greatest-English-Letter-in-Upper-and-Lower-Case/cpp-2309/) | | |
21572158
| | | | | | |
21582159
| 2312 | [Selling Pieces of Wood](https://leetcode.com/problems/selling-pieces-of-wood/) | [] | [C++](2001-2500/2312-Selling-Pieces-of-Wood/cpp-2312/) | | |
21592160
| | | | | | |

0 commit comments

Comments
 (0)