Skip to content

Commit 491a3d3

Browse files
committed
2310 added.
1 parent 03a9615 commit 491a3d3

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

2001-2500/2309-Greatest-English-Letter-in-Upper-and-Lower-Case/cpp-2309/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Source : https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/
22
/// Author : liuyubobobo
3-
/// Time : 2022-06-21
3+
/// Time : 2022-06-18
44

55
#include <iostream>
66
#include <vector>
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(B)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
add_executable(B main.cpp)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/// Source : https://leetcode.com/problems/sum-of-numbers-with-units-digit-k/
2+
/// Author : liuyubobobo
3+
/// Time : 2022-06-18
4+
5+
#include <iostream>
6+
7+
using namespace std;
8+
9+
10+
/// Ad-Hoc
11+
/// Time Complexity: O(1)
12+
/// Space Complexity: O(1)
13+
class Solution {
14+
public:
15+
int minimumNumbers(int num, int k) {
16+
17+
if(num == 0) return 0;
18+
19+
int cnt = 1;
20+
for(cnt = 1; cnt <= 10; cnt ++)
21+
if((cnt * k) % 10 == num % 10)
22+
break;
23+
24+
if(cnt == 11 ||cnt * k > num) return -1;
25+
return cnt;
26+
}
27+
};
28+
29+
30+
int main() {
31+
32+
cout << Solution().minimumNumbers(58, 9) << '\n';
33+
// 2
34+
35+
cout << Solution().minimumNumbers(37, 2) << '\n';
36+
// -1
37+
38+
cout << Solution().minimumNumbers(0, 7) << '\n';
39+
// 0
40+
41+
return 0;
42+
}

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,7 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
21552155
| | | | | | |
21562156
| 2308 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
21572157
| 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/) | | |
2158+
| 2310 | [Sum of Numbers With Units Digit K](https://leetcode.com/problems/sum-of-numbers-with-units-digit-k/) | [] | [C++](2001-2500/2310-Sum-of-Numbers-With-Units-Digit-K/cpp-2310/) | | |
21582159
| | | | | | |
21592160
| 2312 | [Selling Pieces of Wood](https://leetcode.com/problems/selling-pieces-of-wood/) | [] | [C++](2001-2500/2312-Selling-Pieces-of-Wood/cpp-2312/) | | |
21602161
| | | | | | |

0 commit comments

Comments
 (0)