Syntax
C
o
l
o
r
i
z
e
r
Format
public class ReadingBooks { public int countBooks(string[] parts) { int res = 0; int idx = 0; while (idx + 2 < parts.Length) { int delta = 1; if (parts[idx] != parts[idx + 1] && parts[idx + 1] != parts[idx + 2] && parts[idx] != parts[idx + 2]) { res++; delta = 3; } idx += delta; } return res; } }
Autodetect
C
C++
C#
Java
JavaScript
Scala
SQL
Python
XML
Generic
Format
Edit
permlink
public
class
ReadingBooks
{
public
int
countBooks
(
string
[
]
parts
)
{
int
res
=
0
;
int
idx
=
0
;
while
(
idx
+
2
<
parts
.
Length
)
{
int
delta
=
1
;
if
(
parts
[
idx
]
!=
parts
[
idx
+
1
]
&&
parts
[
idx
+
1
]
!=
parts
[
idx
+
2
]
&&
parts
[
idx
]
!=
parts
[
idx
+
2
]
)
{
res
++;
delta
=
3
;
}
idx
+=
delta
;
}
return
res
;
}
}
Edit
For you blog
Insert <br> for newlines
Insert newlines for newlines
Insert for indent
Surround code with <pre> element
For web page
About
|
Send us feedback