FastPrepMinimum Numeric Code Transformation
Problems/Minimum Numeric Code Transformation

Minimum Numeric Code Transformation

Adobe logoAdobe● HardFULLTIMEOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The judged task, five operations, bounds, and sample match the visible source at about 99%.

You receive one reconfiguration request. Start with the positive integer x and transform it into y. Each allowed operation costs exactly one step:

  1. Scale: choose an integer a with 2 <= a <= k and replace the current value v with v * a, only when the result is at most 10^6.
  2. Split: choose an integer a with 2 <= a <= k. If v is divisible by a, replace it with v / a.
  3. Mirror: reverse the decimal digits. Leading zeros produced by reversal are discarded, so 120 becomes 21.
  4. Rotate last to front: move the final decimal digit to the front. This operation is forbidden when it would create a leading zero.
  5. Swap adjacent digits: swap any one adjacent pair. This operation is forbidden when it would create a leading zero.

Every intermediate value must remain between 1 and 10^6, inclusive. Return the minimum number of operations needed to reach y, or -1 when no valid sequence exists.

Function

minimumCodeTransformOperations(x: int, y: int, k: int) → int

Examples

Example 1

x = 4y = 6k = 3return = 2

Scale by 3 to get 12, then split by 2 to get 6. No one-step operation transforms 4 directly into 6.

Example 2

x = 120y = 21k = 10return = 1

One mirror operation reverses 120 to 021; the leading zero is discarded, leaving 21.

Constraints

  • 1 <= x, y <= 10^6
  • 2 <= k <= 10^3

Source note: Public assessment screenshots showing the complete operation rules, bounds, and sample.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int minimumCodeTransformOperations(int x, int y, int k) {
        // Write your solution here
    }
}
Checking account…