-
Notifications
You must be signed in to change notification settings - Fork 7
/
Program.cs
34 lines (33 loc) · 930 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
using System;
using System.Collections.Generic;
namespace ArithmeticSubarrays
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
public IList<bool> CheckArithmeticSubarrays(int[] nums, int[] l, int[] r)
{
var res = new bool[l.Length];
for (int i = 0; i < res.Length; i++)
res[i] = true;
for (int i = 0; i < l.Length; i++)
{
var set = nums[l[i]..(r[i] + 1)];
Array.Sort(set);
var diff = set[1] - set[0];
for (int j = 1; j < set.Length; j++)
{
if (set[j] - set[j - 1] != diff)
{
res[i] = false;
break;
}
}
}
return res;
}
}
}