Problem · Array
Min Amplitude
Learn this problemProblem statement
Given an Array A, find the minimum amplitude you can get after changing up to 3 elements. Amplitude is the range of the array (basically difference between largest and smallest element).
Function
minAmplitude(A: int[]) → intExamples
Example 1
A = [-1, 3, -1, 8, 5, 4]return = 2We can change -1, -1, 8 to 3, 4 or 5.
Example 2
A = [10, 10, 3, 4, 10]return = 0Change 3 and 4 to 10.
Constraints
1 ≤ A.length ≤ 2 * 10^5-10^9 ≤ A[i] ≤ 10^9- You may replace at most three array elements with arbitrary integer values.
More Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026