Ropes left after every removal of smallest | Function print how many Ropes are Left After Every Cutting operation ; Sort all Ropes in increasing order of their length ; min length rope ; Now traverse through the given Ropes in increase order of length ; After cutting if current rope length is greater than '0' that mean all ropes to it 's right side are also  greater than 0 ; Now current rope become min length rope ; After first operation all ropes length become zero ; Driver Code
function cuttringRopes ( Ropes , n ) { Ropes . sort ( ) ; let singleOperation = 0 ; let cuttingLenght = Ropes [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) { if ( Ropes [ i ] - cuttingLenght > 0 ) { document . write ( n - i + " " ) ; cuttingLenght = Ropes [ i ] ; singleOperation ++ ; } } if ( singleOperation == 0 ) document . write ( " " ) ; } let Ropes = [ 5 , 1 , 1 , 2 , 3 , 5 ] ; let n = Ropes . length ; cuttringRopes ( Ropes , n ) ;