Company: Flipkart Hirepro
Difficulty: hard
A super virus is wreaking havoc across the world, and the race is on to find a cure. A novel approach to finding the cure relies on boosting the human body’s immune system by destroying specific virus cells. To destroy a cell, one must first destroy other cells to which it is attached (called its prerequisites ), some of which are virus cells and others are human cells. When a virus cell is destroyed the immune system gets a positive boost, but when a human cell is destroyed the immune system gets a negative boost. The goal is always to boost the immune system as much as possible, so the only reason one would destroy a human cell with a negative boost is because it is a prerequisite to destroy a virus cell with a higher positive boost. There is no cyclicality in the prerequisite structure: it cannot happen that a cell a is to be destroyed for destroying cell b , b is to be destroyed for destroying cell c , and c is to be destroyed for destroying cell a . Given a set of cells, fin