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

Appearance settings

Commit 188c59a

Browse filesBrowse files
committed
Count Binary Substrings
1 parent be8740a commit 188c59a
Copy full SHA for 188c59a

File tree

Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package leetcode2018;
2+
3+
public class CountBinarySubstrings {
4+
5+
public int countBinarySubstrings(String s) {
6+
int t=0;
7+
for(int i =0; i< s.length(); i++){
8+
int n=i+1;
9+
while(n< s.length() && s.charAt(n) == s.charAt(i)){
10+
n++;
11+
}
12+
int m=n+1;
13+
while(m< s.length() && s.charAt(m) == s.charAt(n)){
14+
m++;
15+
}
16+
if((n-i)==(m-n)){
17+
t++;
18+
}
19+
}
20+
return t;
21+
}
22+
23+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.