#User function Template for python3
class Solution():
def lexicographicallyLargest(self, a, n):
#your code here
ans = []
j = 0
for i in range(len(a)):
if (a[i] - a[j]) % 2:
t = a[j:i]
t.sort(reverse=True)
ans.extend(t)
j = i
t = a[j:len(a)]
t.sort(reverse=True)
ans.extend(t)
return ans
No comments:
Post a Comment