Optimizing Box Weights Hackerrank C