Skip to content

Instantly share code, notes, and snippets.

@thilinapiy thilinapiy/isanka.py
Created Jan 28, 2019

Embed
What would you like to do?
#!/bin/env python
# python3.6 filename
def solution(A):
out_of_order_count = 0
existing_hights = A
sorted_hights = sorted(A)
i = 0
j = 0
for tree in existing_hights:
if j < len(existing_hights):
print(existing_hights[i], sorted_hights[j])
if sorted_hights[i] == existing_hights[j]:
pass
else:
j = j + 1
out_of_order_count = out_of_order_count + 1
i = i + 1
j = j + 1
if out_of_order_count < 2:
print("OK")
return 0
else:
print("Nops")
print(out_of_order_count)
return out_of_order_count
solution([2,3,5,4])
solution([4,5,2,3,4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.