SAMSARA Hiring | Minimum Score by Changing Two Elements Problem | Off Campus OA (2024)
Question · Posted Jun 2026
Problem Statement You are given an integer array nums. You are allowed to choose at most two indices in the array and change the values at those indices to any integer value. The score of the array is defined as: score = maximum element - minimum element Return the minimum possible score after performing at most two changes. Example 1 Input nums = [1,4,3] Output 0 Explanation Change: 1 → 3 4 → 3 Array becomes: [3,3,3] Score: 3 - ...
The full answer & interview discussion are available to premium members.
Log in Create a free account