Thursday, 30 March 2023

🗓️ geeksforgeeks problem-of-the-day March, Day 31

 #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

GeeksforGeeks and LeetCode - Problem Of The Day

Welcome to our Problem of the Day Solutions page, where we provide comprehensive solutions to daily programming challenges from two renowned...