bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumGreedyLC 484

Find Permutation

A permutation perm of n integers of all the integers in the range [1, n] can be represented as a string s of length n - 1 where: s[i] == 'I' if perm[i] perm[i + 1]. Given a string s, reconstruct the lexicographically smallest permutation perm and return it.

Asked at 1 company
Google
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode