Amazon Interview Question

Critical edge problem