Find minimum cycle cost per node | Microsoft Interview Question