Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Smallest String After Reverse

med
30 min
Try to solve the Lexicographically Smallest String After Reverse problem.

Statement

You are given a string s of length n.

You may choose an integer k such that 1≤k≤n1 \leq k \leq n, and reverse either the prefix of s of length k or the suffix of s of length k.

Return the lexicographically smallest string that can be obtained after applying this operation.

Constraints:

  • 1≤n==1 \leq n == s.length ≤1000\leq 1000

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Smallest String After Reverse

med
30 min
Try to solve the Lexicographically Smallest String After Reverse problem.

Statement

You are given a string s of length n.

You may choose an integer k such that 1≤k≤n1 \leq k \leq n, and reverse either the prefix of s of length k or the suffix of s of length k.

Return the lexicographically smallest string that can be obtained after applying this operation.

Constraints:

  • 1≤n==1 \leq n == s.length ≤1000\leq 1000

  • s consists of lowercase English letters.