Feasible Indices After Prefix/Suffix Reduction
Updated
Problem statement
Note: this problem is a copy of Feasible Indices After Reduction. The dates when it was seen are now listed on that version.
You are given an integer array arr of size n. All its elements are different.
You can use these two moves any number of times:
- Pick a non-empty prefix of the array: one or more elements taken from its start. Delete every element in it except the smallest one.
- Pick a non-empty suffix of the array: one or more elements taken from its end. Delete every element in it except the largest one.
After each move, the elements that are left join up into a new array.
Call an index i feasible if these moves can shrink the array down to the single element [arr[i]].
Return a binary string of length n, with one character for each index:
1means the index is feasible.0means the index is not feasible.
Function
getFeasibleIndices(arr: int[]) → StringExamples
Example 1
arr = [1, 3, 2, 5, 4]return = "10011"Constraints
1 <= n <= 2 * 10^51 <= arr[i] <= 10^6- All elements are distinct.
More Amazon Online Assessment questions
- Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026
- Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent ElementsOA · PHONE SCREEN · Seen Nov 2026
- Get Smallest Base SegmentOA · Seen Nov 2026
- Minimum Cost of Left and Right PropagationOA · Seen Nov 2026
- Minimum Grid InconvenienceOA · Seen Nov 2026
- Maximize Shipment Order by Sorting One WindowOA · Seen Nov 2026
- Maximum Equal-Bit Pairs in a SubsequenceOA · Seen Nov 2026
- First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
- Two SumOA · PHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Minimum Cost to Merge Values into OnePayPal · OAPayPal interview questions
- Minimum Operations to Sort with Rotations Then SwapsBank of New York Mellon · OA
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Reschedule Meetings for Maximum Free TimeFivetran · OAFivetran interview questions
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
- Maximum ScoreNVIDIA · OANVIDIA interview questions
- Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
- Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company · OAMcKinsey & Company interview questions
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions