-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathBROKPHON.c
44 lines (40 loc) · 822 Bytes
/
BROKPHON.c
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
40
41
42
43
44
// https://www.codechef.com/problems/BROKPHON
#include <stdio.h>
/* 7 1 1 1 3 3 3 2
*/
// Got accepted in the first time.
// No Explaination used.
// By Mohd Azeem
int main()
{
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++)
{
int n;
scanf("%d", &n);
int array[n];
for (int i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
int count = 0;
if (array[0] != array[1])
{
count++;
}
for (int i = 1; i < n - 1; i++)
{
if (array[i] != array[i - 1] || array[i] != array[i + 1])
{
count++;
}
}
if (array[n - 1] != array[n - 2])
{
count++;
}
printf("%d\n", count);
}
return 0;
}