Minimize the Maximum Array Element
Updated
Problem statement
You are given a nonempty array arr of nonnegative integers. You may perform the following operation zero or more times.
Choose integers l, r, and i such that 0 <= l < r < arr.length, 0 <= i < r, and every derived index is valid: l + r < arr.length and l + i < arr.length. Then assign arr[l + r] = arr[l + i] & arr[r - i], where & is bitwise AND.
Return the minimum possible value of the maximum array element after any finite sequence of legal operations.
Function
minimizeMaximumElement(arr: int[]) → intExamples
Example 1
arr = [5,12,10,7]return = 5Index 0 can never be an operation target. A legal sequence can reduce every later value to at most 5, so the optimum is 5.
Example 2
arr = [0,15,9]return = 0First set index 1 using (l,r,i)=(0,1,0), then set index 2 using (0,2,1).
Constraints
1 <= arr.length <= 200000.0 <= arr[i] <= 1000000000.- You may perform zero operations.
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
- 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
- Minimum Last-Element RelocationsOA · Seen Sep 2026
- Most Visited Sprint MarkerOA · Seen Sep 2026
- How Many Sentences?OA · Seen Sep 2026
Similar questions at other companies
- Minimum Halvings for Alternating ParityIBM · OAIBM interview questions
- Server SelectionPoint72 · OAPoint72 interview questions
- Minimum Servers for an Exact LoadJP Morgan Chase · OAJP Morgan Chase interview questions
- Get Max Or SumMicrosoft · OAMicrosoft interview questions
- Maximize PartitionsAmazon · OA
- Fewest Steps to Build an Array from ZerosExpedia · OAExpedia interview questions
- Maximum XOR Elimination ScoreRippling · OARippling interview questions
- Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
- Minimum Row Deletions to Prevent a Target ORInMobi · ONSITE INTERVIEWInMobi interview questions
- Earn the Most 🐝Capital One · OACapital One interview questions