Google Interview Question

basically code prims algorithm