DP World interview question

Connect n ropes with minimum cost