Company: Amazon_4th june_on campus _iit guwahti

Difficulty: medium

Problem Statement

Efficient Tasks Split the given module difficulties into three nonempty labeled groups. After a split, choose one difficulty d1 , d2 , and d3 from groups 1, 2, and 3 respectively. Its score is |d1-d2| + |d2-d3| . The split's value is the minimum score among all its possible selections. Print the maximum split value. Input Format The first line contains n . The second line contains n difficulties. Output Format Print the maximum possible value. Constraints 3 <= n <= 200000 1 <= difficulty[i] <= 10^9 Example Input: 5 1 2 5 3 5 Output: 6 Notes Every module belongs to exactly one group, and every group must be nonempty.

More Amazon_4th june_on campus _iit guwahti OA questionsInterview experiences