-
Notifications
You must be signed in to change notification settings - Fork 7
/
Program.cs
39 lines (38 loc) · 921 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.ComponentModel;
namespace CheckIfAll1_sAreAtLeastLengthKPlacesAway
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
static bool KLengthApart(int[] nums, int k)
{
int index = 0;
int space = 0;
for (int i = 0; i < nums.Length; i++)
{
if (nums[i] == 1)
{
index = i + 1;
break;
}
}
while (index < nums.Length)
{
if (nums[index] == 0)
space++;
else
{
if (space < k)
return false;
space = 0;
}
index++;
}
return true;
}
}
}