FastPrepMinimum Last-Element Relocations
Problems/Minimum Last-Element Relocations

Minimum Last-Element Relocations

Chubb logoChubb● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names this algorithm exercise. We chose the function signature, the limits, the rules for fixed answers, and the examples.

The arrays current and desired contain the same multiset of values. In one operation, remove the last element of the current array and insert it at any position.

Return the minimum number of operations needed to transform current into desired.

Function

minimumRelocations(current: int[], desired: int[]) → int

Examples

Example 1

current = [2,1,3,5,4]desired = [2,4,1,5,3]return = 2

The unmatched suffix is exactly the set of elements that must be extracted and reinserted.

Example 2

current = [1,2,3]desired = [1,2,3]return = 0

The unmatched suffix is exactly the set of elements that must be extracted and reinserted.

Example 3

current = [1,2,3]desired = [3,2,1]return = 2

The unmatched suffix is exactly the set of elements that must be extracted and reinserted.

Constraints

  • 1 <= current.length == desired.length <= 200000.
  • The arrays contain the same multiset.

Source note: Author-written prompt excerpt retained for source fidelity.

More Chubb Online Assessment questions

  • Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
  • Index of the Maximum After Left RotationsOA · Seen Oct 2026
  • Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
  • Minimize the Maximum Array ElementOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Flat JSON Value DifferencesOA · Seen Sep 2026
  • Maximum Student-Teacher DistanceOA · Seen Sep 2026
  • Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
  • Most Visited Sprint MarkerOA · Seen Sep 2026
  • How Many Sentences?OA · Seen Sep 2026

Similar questions at other companies

  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Generating Login CodesSnowflake · OASnowflake interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
  • Minimum Adjacent Merges to Form a PalindromeArista Networks · OAArista Networks interview questions
  • Minimum Storage CapacityAmazon · OA
  • Minimum Machines for TasksExpedia · OAExpedia interview questions
  • Frog Game 🐸Microsoft · OAMicrosoft interview questions
  • Find Minimum Possible SizeMathWorks · OAMathWorks interview questions
  • Minimum Days to Watch All MoviesAdobe · OAAdobe interview questions
All Chubb interview questionsSee Chubb hiring insights
Saved
class Solution {
    public int minimumRelocations(int[] current, int[] desired) {
        // Write your code here.
    }

}
Checking account…