Skip to content

Commit d925abf

Browse files
authored
Initial File
Maximum Difference of Binary Tree
1 parent 80c74cd commit d925abf

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

max_diff.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def max_diff_ele(arr):
2+
arr=sorted(arr)
3+
size=len(arr)
4+
5+
diff = - 999*999
6+
7+
for i in range(size-1):
8+
if(arr[i+1]-arr[i]>diff):
9+
diff=arr[i+1]-arr[i]
10+
return diff
11+
12+
arr=[ 5 , 32 , 45 , 4 , 12 , 18 , 25 ]
13+
print("Maximum difference between array elements is",max_diff_ele(arr))
14+
15+
16+
17+
18+
19+
20+
21+

0 commit comments

Comments
 (0)