-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathaccsort.py
More file actions
25 lines (25 loc) · 699 Bytes
/
accsort.py
File metadata and controls
25 lines (25 loc) · 699 Bytes
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
import copy
q = int(raw_input().strip())
for k in xrange(q):
n = int(raw_input().strip())
a = map(int, raw_input().strip().split(' '))
org=copy.copy(a)
length=len(a)-1
a=sorted(a)
# for i in range(0,length):
# for j in range(0,length-i):
# if(a[j]>a[j+1]):
# temp=a[j]
# a[j]=a[j+1]
# a[j+1]=temp
for i in range(0,length):
for j in range(0,length-i):
if(abs(org[j]-org[j+1])==1):
if(org[j]>org[j+1]):
temp=org[j]
org[j]=org[j+1]
org[j+1]=temp
if(a==org):
print "Yes"
else:
print "No"