DEV Community

Miss Pooja Anilkumar Patel
Miss Pooja Anilkumar Patel

Posted on

899. Leetcode Solution in Python3

class Solution:
  def orderlyQueue(self, S: str, K: int) -> str:
    return ''.join(sorted(S)) if K > 1 else min(S[i:] + S[:i] for i in range(len(S)))

Enter fullscreen mode Exit fullscreen mode

leetcode

challenge

Here is the link for the problem:
https://leetcode.com/problems/orderly-queue/description/

Top comments (0)