Microsoft OA | IIT Madras | SWE Internship | 2023

Microsoft · Question · Posted Jul 2023

Question 1.   There is an array A consisting of N integers. Divide them into three non-empty groups. In each group we calculate the difference between the largest and smallest integer. Our goal is to make the maximum of these differences as small as possible. For example, given A=[11, 5,3, 12, 6, 8, 1, 7, 4], we can divide the elements into three groups: [3, 1, 4] - the difference between elements is 3; [5, 6, 8, 7] - the ...

The full answer & interview discussion are available to premium members.

Log in Create a free account