Skip to content

Commit 2703152

Browse files
BarklimBarklim
Barklim
authored and
Barklim
committed
Create 3208.js
1 parent ec67269 commit 2703152

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

example/Dayly/3208.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @param {number[]} colors
3+
* @param {number} k
4+
* @return {number}
5+
*/
6+
var numberOfAlternatingGroups = function(colors, k) {
7+
8+
};
9+
10+
const example1 = numberOfAlternatingGroups([0,1,0,1,0], 3); // 3
11+
const example2 = numberOfAlternatingGroups([0,1,0,0,1,0,1], 6); // 2
12+
const example3 = numberOfAlternatingGroups([1,1,0,1], 4); // 0
13+
const example4 = numberOfAlternatingGroups([1,1,1,1,1,1,0,1], 2); // 2
14+
15+
console.log(example1);
16+
console.log(example2);
17+
console.log(example3);
18+
console.log(example4);
19+
20+
// var numberOfAlternatingGroups = function(colors, k) {
21+
// colors.push(...colors.slice(0, k - 1));
22+
// let begin = 0;
23+
// let result = 0;
24+
25+
// for (let end = 0; end < colors.length; end++) {
26+
// if (colors[end] === colors[end - 1]) {
27+
// begin = end
28+
// }
29+
30+
// if (end - begin + 1 >= k) {
31+
// result++
32+
// }
33+
// }
34+
35+
// return result
36+
// };

0 commit comments

Comments
 (0)