Maximum Weighted End-Pick Score
Updated
Problem statement
Choose exactly multipliers.length numbers from nums. At each step, remove either the first or last remaining number. Multiply the number chosen at zero-based step i by multipliers[i] and add it to the score.
Return the largest possible total score. The multiplier order is fixed, and every multiplier must be used, even when all possible totals are negative.
Function
maximumWeightedEndScore(nums: int[], multipliers: int[]) → longExamples
Example 1
nums = [1,2,-3,4]multipliers = [1,1,-1,-1]return = 6Pick 1, 4, -3, 2: their weighted total is 1 + 4 + 3 - 2 = 6.
Example 2
nums = [1,2,3]multipliers = [3,2]return = 13Choose 3 and then 2 from the right: 3 * 3 + 2 * 2 = 13.
Example 3
nums = [-5,-2,-4]multipliers = [1,1]return = -6Choose -4 and then -2; exactly two picks are required.
Constraints
1 <= nums.length <= 100000.1 <= multipliers.length <= min(nums.length, 200).- Every number and multiplier lies between
-10^6and10^6. - Return a signed 64-bit total.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
- Trapping Rain WaterOracle · PHONE SCREENOracle interview questions
- Minimum Length After Removing Arithmetic TriplesMedia.net · PHONE SCREEN
- Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
- Longest Consistent Activity StreakAtlassian · PHONE SCREENAtlassian interview questions
- Longest Increasing Path in a MatrixNew Relic · PHONE SCREEN · ONSITE INTERVIEW
- Longest Increasing Subsequence With Bounded Adjacent DifferenceAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Maximum Profit with at Most K TransactionsTekion · PHONE SCREENTekion interview questions
- Count Ordered Combination Sums with Negative ValuesPinterest · PHONE SCREENPinterest interview questions
- Minimum Matrix-Chain MultiplicationsGSA Capital · PHONE SCREEN