FastPrepDoing Smart Work
Problems/Doing Smart Work

Doing Smart Work

Rubrik logoRubrik● MediumOA

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

Given a decimal digit string a, perform the following operation any number of times, including zero:

  • Swap two adjacent digits only when one digit is even and the other is odd.

Return the smallest string obtainable. Leading zeros are preserved.

Function

getMinimumNumber(a: String) → String

Examples

Example 1

a = "4321"return = "3142"

The even digits keep their relative order 4, 2, and the odd digits keep their relative order 3, 1. The smallest valid merge is 3142.

Constraints

  • 1 <= a.length <= 10^5.
  • a contains only decimal digits.

More Rubrik interview questions

  • Colored Rooted TreeONSITE INTERVIEW · Seen Nov 2026
  • Delete and Freeze GameOA · Seen Nov 2026
  • Delete K Subsets for Maximum ScoreOA · Seen Nov 2026
  • Distribute Elements Into Two Arrays IIOA · Seen Nov 2026
  • Minimum Replacements to Sort the ArrayOA · Seen Nov 2026
  • All Balanced Strings from Minimum Parenthesis InsertionsONSITE INTERVIEW · Seen Nov 2026
  • Insert into a Left-Complete Binary TreeONSITE INTERVIEW · Seen Oct 2026
  • Thread-Safe Request Counts by AttributeONSITE INTERVIEW · Seen Oct 2026
  • Minimum Swaps To Binary PalindromeOA · Seen Apr 2026
  • Get Minimum OperationsOA · Seen Nov 2024

Similar questions at other companies

  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Return Exact Cash Register ChangeBank of America · OABank of America interview questions
  • Largest Binary Number by ConcatenationAdobe · OAAdobe interview questions
  • Maximize Palindromic WordsSquarepoint Capital · OASquarepoint Capital interview questions
  • Swap Parity (Data Scientist / Analytics :)JP Morgan Chase · OAJP Morgan Chase interview questions
  • Swap ParityPalantir · OAPalantir interview questions
  • Join Numbers into the Largest ValueExpedia · ONSITE INTERVIEWExpedia interview questions
  • Hiking Club Fastest PaceInfosys · OAInfosys interview questions
  • Maximum String OperationsMicrosoft · OAMicrosoft interview questions
  • Minimum No-Repeat Segments After One Character RemovalSalesforce · OASalesforce interview questions
All Rubrik interview questionsSee Rubrik hiring insights
Saved
class Solution {
    public String getMinimumNumber(String a) {
      // write your code here
    }

}
Checking account…