FastPrepSum of Mutated Array Closest to Target
Problems/Sum of Mutated Array Closest to Target

Sum of Mutated Array Closest to Target

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported as a sorting-and-replacement array variation in a first-hand Bloomberg 2020 new-grad onsite. The standard closest-target and smaller-tie contract makes the variant executable.

Choose a nonnegative integer cap. Replace every nums[i] > cap by cap and leave smaller values unchanged. Return the cap whose mutated-array sum is closest to target; break ties by smaller cap.

Function

findBestValue(nums: int[], target: int) → int

Examples

Example 1

nums = [4,9,3]target = 10return = 3

Cap 3 gives sum 9, closer than cap 4's sum 11; the distances tie, so choose 3.

Constraints

  • 1 <= nums.length <= 10^5.
  • Values and target are positive integers.

More Bloomberg LP Onsite Interview questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Count Winning Dice Face PairsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Aggressive CowsAmazon · PHONE SCREEN
  • Classify Heap Addresses from a Memory SnapshotSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • Maximize the Minimum Cone DistanceSumo Logic · PHONE SCREEN
  • Count Triples That Can Form a TriangleAdobe · PHONE SCREENAdobe interview questions
  • Room Occupancy at Query TimesWhatNot · ONSITE INTERVIEWWhatNot interview questions
  • HTTP Log QueriesDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Smallest Common Integer in Sorted ListsMotive · ONSITE INTERVIEWMotive interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int findBestValue(int[] nums, int target) {
      // Write your code here.
    }
}
Checking account…