Skip to content

Commit b9987ed

Browse files
authored
Create Check-if-array-is-sorted.py
1 parent 17b806d commit b9987ed

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#User function Template for python3
2+
3+
class Solution:
4+
def arraySortedOrNot(self, arr, n):
5+
# code here
6+
for i in range(n-1):
7+
if arr[i] > arr[i+1]:
8+
return 0
9+
return 1
10+
11+
12+
#{
13+
# Driver Code Starts
14+
#Initial Template for Python 3
15+
16+
if __name__ == '__main__':
17+
tc = int(input())
18+
while tc > 0:
19+
n = int(input())
20+
arr = list(map(int, input().strip().split()))
21+
22+
ob = Solution()
23+
ans = ob.arraySortedOrNot(arr, n)
24+
if ans:
25+
print(1)
26+
else:
27+
print(0)
28+
tc -= 1
29+
30+
# } Driver Code Ends

0 commit comments

Comments
 (0)