My issue
Not Being able to come with a Logic. Everyone else have used a logic that is being generated by an AI
My code
# cook your dish here
def check(x,l):
count=0
for i in range (l-1):
if l>1:
if x[i]!=x[i+1]:
count=count+1
x[i:i+2] = [x[i],x[i]]
else:
continue
else:
return print("1")
print(count)
t = int(input())
for _ in range(t):
n = int(input())
A = list(map(int, input().split()))
x = list(set(A))
l = len(x)
check(x, l)
Learning course: Arrays, Strings & Sorting
Problem Link: Practice Problem in - CodeChef