Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
Backend Engineer Senior programming

Implement a function that returns all unique permutations of a given string, ensuring that the output is sorted lexicographically.


Constraints:


  • Str length from 1 to 8. Each character is a lowercase letter.


Examples:


1. Input: 'zyx'
Output: ['xyz', 'xzy', 'yxz', 'yzx', 'zxy', 'zyx']
2. Input: 'bca'
Output: ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free
Link copied to clipboard