You have two ropes,each of them takes 1 hour to burn.But either rope has varying density so there is no consistency in time that it takes to burn for different section.How do you use these two ropes to calculate 45 minutes.
Take two ropes. Put them side by side parallal Light top of first rope and down of another rope When the flames meet that means 30 minutes elapsed At the instant when they meet light the bottom of the first rope or top of another rope. When it finishes 15 minutes elapsed. So(30+15)=45 minutes.
burn rope1 from both sides and rope 2 from 1 side. after 30 mins rope 1 will burn completely. now burn the other end of rope 2 it will burn in another 15 mins.
Given an integer n, write a function that returns count of trailing zeroes in n!. Examples: Input: n = 5 Output: 1 Factorial of 5 is 20 which has one trailing 0. Input: n = 20 Output: 4 Factorial of 20 is 2432902008176640000 which has 4 trailing zeroes. Input: n = 100 Output: 24
Take two ropes.
ReplyDeletePut them side by side parallal
Light top of first rope and down of another rope
When the flames meet that means 30 minutes elapsed
At the instant when they meet light the bottom of the first rope or top of another rope.
When it finishes 15 minutes elapsed.
So(30+15)=45 minutes.
As mentioned the ropes have varying density so it can not be guaranteed that when 30 minutes is elapsed they both will meet at some point.
ReplyDeleteburn rope1 from both sides and rope 2 from 1 side.
ReplyDeleteafter 30 mins rope 1 will burn completely.
now burn the other end of rope 2 it will burn in another 15 mins.
This comment has been removed by the author.
ReplyDeletefold 1st rope from the middle and burn both the ends...once it gets burnt, burn the other rope from both ends.
ReplyDeleteyeah both approaches are correct...
ReplyDelete