Data Reorganization
Updated
Problem statement
While analyzing data, you are working with an array data containing n positive integers, each representing a dataset values.
To derive new features for data analysis, you can perform the following operations:
(i,j) (0-based) such that 0 ≤ i < j < len(data).|data[i] - data[j]|.data, increasing its length by 1.
The objective is to minimize the smallest value present in data after performing exactly maxOperations operations.
Write a program to compute the minimum possible value of the smallest element in data after the given operations.
Function
getMinimumValue(data: int[], maxOperations: int) → int
Complete the function getMinimumValue in the editor with the following parameters:
int data[]: the datasetint maxOperations: the number of operations to be performed
Returns
int: the smallest possible value of the minimum element in data after exactly maxOperations operations.
Constraints
2 ≤ n ≤ 2*10^31 ≤ data[i] ≤ 10^91 ≤ maxOperations ≤ 10^9
🍻 Many, many thanks to one of our dearest and very best friends for being with FastPrep every step of the way! (Oct 17, 2025 :) 🧡
Examples
Example 1
data = [42, 47, 50, 54, 62, 79]maxOperations = 2return = 3The underlined values are selected for each operation. One optimal sequence is:
| Operation Number | data[] before | data[] after |
|---|---|---|
| 1 | [42, 47, 50, 54, 62, 79] | [42, 47, 50, 54, 62, 79, 15] |
| 2 | [42, 47, 50, 54, 62, 79, 15] | [42, 47, 50, 54, 62, 79, 15, 3] |
The first operation appends |47 - 62| = 15. The second appends |47 - 50| = 3. The smallest possible value of the minimum element is 3.
Example 2
data = [4, 2, 5, 9, 3]maxOperations = 1return = 1The underlined values are selected for the operation. One optimal operation is:
| Operation Number | data[] before | data[] after |
|---|---|---|
| 1 | [4, 2, 5, 9, 3] | [4, 2, 5, 9, 3, 1] |
The operation appends |4 - 3| = 1. The smallest possible value of the minimum element is 1.
Example 3
data = [5, 18, 3, 12, 11]maxOperations = 2return = 1Constraints
See the very last portion of the problem statement above 👆
More Goldman Sachs interview questions
- House Robber IIIPHONE SCREEN · Seen Nov 2026
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
- Maximum Ones After K OperationsOA · Seen Nov 2026
- Palindrome CounterOA · Seen Oct 2026
- Longest Palindromic SubsequenceOA · Seen Oct 2026
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Minimum BeautyBloomberg LP · OABloomberg LP interview questions
- Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Split Array Largest SumAuxoAI · OA
- Find Optimal LevelAmazon · OA
- Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
- Array NullificationQRT · OA
- Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions