Caterpillar Interview Question

If problem A, How do you solve?