FastPrepLexicographically Minimum Stack Encryption
Problems/Lexicographically Minimum Stack Encryption

Lexicographically Minimum Stack Encryption

Rippling logoRippling● MediumOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by a real Rippling OA report that directly provides both legal stack operations and two visible input-output examples. Estimated match rate: 95-98% for the judged task. The report did not provide numeric limits or an exact function signature.

You are given a string originalString. Start with two empty strings: temporaryString and encryptedString.

Repeat either of the following operations until both originalString and temporaryString are empty:

  • Remove the first character of originalString and append it to temporaryString.
  • Remove the last character of temporaryString and append it to encryptedString.

Choose the operation order that produces the lexicographically smallest possible encryptedString, and return that string.

Function

minimumEncryptedString(originalString: String) → String

Examples

Example 1

originalString = "dby"return = "bdy"

Move d and then b into the temporary stack. Pop b first, then arrange the remaining legal moves to produce bdy.

Example 2

originalString = "vgxgpu"return = "ggpuxv"

The minimum legal encrypted string is ggpuxv.

Constraints

  • 1 <= originalString.length() <= 200000
  • originalString contains lowercase English letters.

More Rippling problems

  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
All Rippling interview questionsSee Rippling hiring insights
Saved
public String minimumEncryptedString(String originalString) {
  // write your code here
}
Checking account…