#3720

Lexicographically Smallest Permutation Greater Than Target

expert · 1150 · lc medium +32 · 26.5% accepted · 113 likes · top 5%

Description

Given two same-length strings s and target of lowercase letters, return the lexicographically smallest permutation of s that is strictly greater than target, or an empty string if no such permutation exists.

Code

1
2
3