We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 82226c6 commit e7339efCopy full SHA for e7339ef
1 file changed
wave_array
@@ -0,0 +1,11 @@
1
+def wave( arr ):
2
+ size=len(arr)
3
+
4
+ for index in range(0,size,2):
5
+ if((index > 0) and (arr[index-1] > arr[index])):
6
+ arr[index-1] , arr[index] = arr[index] , arr[index-1]
7
8
+ if((index < size-1) and (arr[index] < arr[index+1])):
9
+ arr[index] , arr[index+1] = arr[index+1] , arr[index]
10
11
+ return arr
0 commit comments