Answer: BAKER HUGHES Hiring Challenge | Online Assessment Question | On-Campus (2024)

Answer · Posted Jun 2026

Approach Sort the special floors. Calculate: Gap before the first special floor. Gaps between consecutive special floors. Gap after the last special floor. Return the maximum gap. Strategy Sort the special array. Compare every consecutive pair of special floors. Keep updating the maximum gap found. Return the largest consecutive non-special floor count. Java Code import java.util.Arrays; class Solution { public int maxConsecutive(int bottom, int top, int[] special) { Arrays.sort(special); int maxFloors = 0; maxFloors = Math.max(maxFloors, special[0] - bottom); for ...

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

Log in Create a free account