Skip to content

Commit 6774df8

Browse files
committed
2255 solved.
1 parent eb5aadd commit 6774df8

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-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(cpp_2255)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
add_executable(cpp_2255 main.cpp)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// Source : https://leetcode.com/problems/count-prefixes-of-a-given-string/
2+
/// Author : liuyubobobo
3+
/// Time : 2022-04-30
4+
5+
#include <iostream>
6+
#include <vector>
7+
8+
using namespace std;
9+
10+
11+
/// Brute Force
12+
/// Time Complexity: O(n * |s|)
13+
/// Space Complexity: O(|s|)
14+
class Solution {
15+
public:
16+
int countPrefixes(vector<string>& words, string s) {
17+
18+
int res = 0;
19+
for(const string& word: words){
20+
res += (word.size() <= s.size() && s.substr(0, word.size()) == word);
21+
}
22+
return res;
23+
}
24+
};
25+
26+
27+
int main() {
28+
29+
return 0;
30+
}

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
226226
| | | | | | |
227227
| 181 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
228228
| | | | | | |
229+
| 184 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
230+
| | | | | | |
229231
| 186 | [Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii/description/) | [] | [C++](0001-0500/0186-Reverse-Words-in-a-String-II/cpp-0186/) | | |
230232
| | | | | | |
231233
| 188 | [Best-Time-to-Buy-and-Sell-Stock-IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/description/) | | [C++](0001-0500/0188-Best-Time-to-Buy-and-Sell-Stock-IV/cpp-0188/) | | |
@@ -595,6 +597,7 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
595597
| 575 | [Distribute Candies](https://leetcode.com/problems/distribute-candies/) | [solution](https://leetcode.com/problems/distribute-candies/solution/) | [C++](0501-1000/0575-Distribute-Candies/cpp-0575/) | | |
596598
| 576 | [Out of Boundary Paths](https://leetcode.com/problems/out-of-boundary-paths/) | [solution](https://leetcode.com/problems/out-of-boundary-paths/solution/) | [C++](0501-1000/0576-Out-of-Boundary-Paths/cpp-0576/) | | |
597599
| | | | | | |
600+
| 580 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
598601
| 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray/) | [solution](https://leetcode.com/problems/shortest-unsorted-continuous-subarray/solution/)<br/>[缺:Stack] | [C++](0501-1000/0581-Shortest-Unsorted-Continuous-Subarray/cpp-0581/) | | |
599602
| 582 | [Kill Process](https://leetcode.com/problems/kill-process/) | [solution](https://leetcode.com/problems/kill-process/solution/) | [C++](0501-1000/0582-Kill-Process/cpp-0582/) | | |
600603
| 583 | [Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings/description/) | [solution](https://leetcode.com/problems/delete-operation-for-two-strings/solution/) | [C++](0501-1000/0583-Delete-Operation-for-Two-Strings/cpp-0583/) | | |
@@ -2089,6 +2092,7 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
20892092
| 2252 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
20902093
| 2253 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
20912094
| 2254 | [Design Video Sharing Platform](https://leetcode.com/problems/design-video-sharing-platform/) | [] | [C++](2001-2500/2254-Design-Video-Sharing-Platform/cpp-2254/) | | |
2095+
| 2255 | [Count Prefixes of a Given String](https://leetcode.com/problems/count-prefixes-of-a-given-string/) | [] | [C++](2001-2500/2255-Count-Prefixes-of-a-Given-String/cpp-2255/) | | |
20922096
| | | | | | |
20932097

20942098
## 力扣中文站比赛

0 commit comments

Comments
 (0)