Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f986b8c

Browse files
solved leetcode daily challenge
See: Why: How: Tags:
1 parent 37ab00a commit f986b8c

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

‎LeetCode/Max_Consecutive_Ones/main.cxx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <bits/stdc++.h>
2+
#include <gtest/gtest.h>
3+
using namespace std;
4+
5+
6+
//// START
7+
/*
8+
## Max Consecutive Ones
9+
10+
*/
11+
class Solution {
12+
public:
13+
int findMaxConsecutiveOnes(vector<int>& nums) {
14+
int ret = 0;
15+
int c = 0;
16+
if (nums[0] == 1){
17+
c = 1;
18+
ret = 1;
19+
}
20+
for (int i = 1;i < nums.size();i++){
21+
if (nums[i] == 0){
22+
c = 0;
23+
continue;
24+
}
25+
if (nums[i] == nums[i-1]){
26+
c++;
27+
}else{
28+
c = 0;
29+
}
30+
ret = max(ret,c);
31+
}
32+
return ret;
33+
34+
}
35+
};
36+
37+
38+
39+
//// END
40+
struct T{
41+
42+
};
43+
44+
TEST(Solution,test){
45+
T ts[] = {
46+
{
47+
48+
},
49+
{
50+
51+
},
52+
53+
};
54+
55+
56+
for (T t : ts){
57+
Solution solution;
58+
59+
}
60+
}
61+
62+
int main() {
63+
testing::InitGoogleTest();
64+
65+
return RUN_ALL_TESTS();
66+
}
67+
68+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /