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

add 172 folder & cpp, add 190 folder & cpp, add 434 folder & cpp #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
yanglbme merged 1 commit into doocs:master from zouwx2cs:master
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions solution/172.Factorial Trailing Zeroes/Solution.cpp
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution {
public:
int trailingZeroes(int n) {
int cnt5 = 0 ;
for (long long i = 5; i <= n; i *= 5)
cnt5 += n/i ;
return cnt5 ;
}
};
16 changes: 16 additions & 0 deletions solution/190.Reverse Bits/Solution.cpp
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t res = 0 ;
uint32_t tmp = 1 << 31 ;
while (n)
{
if (n&1)
res |= tmp ;
tmp >>= 1 ;
n >>= 1 ;
}

return res ;
}
};
13 changes: 13 additions & 0 deletions solution/434.Number of Segments in a String/Solution.cpp
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:
int countSegments(string s) {
if (s.length() < 1)
return 0 ;

int cnt = isspace(s[0])? 0: 1 ;
for (int i = 1; i < s.length(); ++i)
if (!isspace(s[i]) && isspace(s[i-1]))
++cnt ;
return cnt ;
}
};

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