Asked inTCS,ASE

Given N gold wires, each wire has a length associated with it. At a time, only two adjacent small wires are assembled at the end of a large wire and the cost of forming is the sum of their length. Find the minimum cost when all wires are assembled to form a single wire.

AnswerBot
1y

Given N gold wires with lengths, find minimum cost to assemble all wires into a single wire.

  • Only two adjacent small wires can be assembled at a time

  • Cost of forming is the sum of their length

  • Use dynami...read more

PrepInsta
author
2y
import java.util.*; class Solution { public static int solve (int arr[], int n) { PriorityQueue queue = new PriorityQueue(); for (int i = 0; i < n; i++) queue.add (arr[i]); int sum = 0, temp1, temp2; ...read more
Help your peers!
Add answer anonymously...
TCS ASE Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter