Minimum Operations to Make a Subsequence
Updated
Problem statement
Given an integer array target whose values are all distinct and an integer array arr that may contain repeated values, return the minimum number of operations needed to make target a subsequence of arr.
In one operation, you insert one integer of your choice into arr at any position: at the start, at the end, or between two elements.
Examples
Example 1
target = [4,7,2]arr = [7,5,2,7]return = 1The values 7 and 2 already appear in this order in arr. Insert 4 at the start to get [4,7,5,2,7], which contains [4,7,2] as a subsequence.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$99 billed yearly — or $19 month-to-month. Cancel anytime.
More Google Online Assessment questions
- Book Reading EveningsOA · Seen Nov 2026
- Count Score CategoriesOA · Seen Nov 2026
- Minimum Cars for Rental RequestsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Shortest Path in a Binary MatrixOA · Seen Nov 2026
- Robot Assembly Line ConflictsOA · Seen Oct 2026
- Assign LockerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Biggest Number From DigitsOA · Seen Oct 2026
- Consolidate On-Call RotationsOA · PHONE SCREEN · Seen Oct 2026
- Decreasing SubsequencesOA · Seen Sep 2026
- Minimize Absolute Difference of Server LoadsOA · Seen Sep 2026
Similar questions at other companies
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Split Array Largest SumAuxoAI · OA
- Data ReorganizationGoldman Sachs · OAGoldman Sachs interview questions
- Find Optimal LevelAmazon · OA
- Array Reduction AlgorithmSnowflake · OASnowflake interview questions
- Count Pairs of Overlapping SquaresCapital One · OACapital One interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
- Minimum Distinct Prefix CostChubb · OAChubb interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions