Answer: RAYTHEON TECHNOLOGIES | Interview Question | Off-Campus (2022)

Answer · Posted Jun 2026

Approach Traverse the balloons from left to right. Whenever consecutive balloons have the same color: Keep the balloon with the maximum removal time. Remove the others. Accumulate the removal cost. Strategy Use a Greedy approach. For every consecutive group of the same color: Retain the balloon with the highest removal cost. Remove all remaining balloons. This guarantees the minimum removal cost. Java Code class Solution { public int minCost(String colors, int[] neededTime) { int totalCost = 0; int maxTime = ...

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

Log in Create a free account