Minimum Vector Read and Rotate Uses
Updated
Problem statement
An unknown vector has length indexed entries. You can use either of two machines:
- The read machine reveals the current first entry.
- The rotation machine shifts entries 2 through n one place left and moves the first entry to the last position.
Find the minimum total number of machine uses needed to read every original indexed entry. For this exercise, assume each use costs one operation, a read does not modify the vector, each rotation persists, and an entry must actually be read even if its value equals another entry or could be guessed.
For this exercise, assume length is the supplied positive integer and the result is an exact signed 64-bit integer. Complete minimumMachineUses(length).
Function
minimumMachineUses(length: long) → longExamples
Example 1
length = 1return = 1One front read reveals the only entry; no rotation is needed.
Example 2
length = 3return = 5Read, rotate, read, rotate, read reveals all three indexed entries using five machine operations.
Example 3
length = 5return = 9Five reads and four rotations are sufficient. A rotation after the final read would add an unnecessary operation.
Constraints
- For this exercise, assume
1 <= length <= 1000000000000. - Only one-position left rotations and front reads are allowed.
- Every use of either machine counts toward the objective.
More IMC Trading Online Assessment questions
- Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
- Grid Paths with Override PassesOA · Seen Oct 2026
- Weighted LFU CacheOA · Seen Sep 2026
- Rock JumpingOA · Seen Aug 2026
- Stack Batch RemovalOA · Seen Aug 2026
- Chain of CommandOA · Seen Aug 2026
- Choose ContainersOA · Seen Aug 2026
- Sub-matrix SumsOA · Seen Jul 2026
- Sub-matrix SumsOA · Seen Jul 2026
- Can Every Package Fit in a BoxOA · Seen Jul 2026
Similar questions at other companies
- Summarize Taxi Drivers and RidesBoston Consulting Group · OABoston Consulting Group interview questions
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count Valid Square PairsAuxoAI · OA
- Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Identification Number Check DigitAbridge · OAAbridge interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions