You have five pieces of chain, each consisting of three links. You want to make one long chain of these five pieces. Breaking open a link costs 1 Rs, and welding an open link costs 3 Rs.
Is it possible to make one long chain of the five pieces, if you have just 15 Rs?
Solution:
Let us name the chains as 1, 2, 3, 4, 5 each having three links.
Take chain 1 and break open all three links: 1×3=3 Rs.
Take one open link to connect chain 2 and 3: 3 Rs.
Take another open link to connect chain 3 and 4: 3 Rs
Take third open link to connect chain 4 and 5: 3 Rs.
Now you have one long chain ready in only 12 Rs
This article is contributed by Shivam Gupta. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.



