Ropes left after every removal of smallest | Java program to print how many Ropes are Left After Every Cut ; 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
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { public static void cuttringRopes ( int Ropes [ ] , int n ) { Arrays . sort ( Ropes ) ; int singleOperation = 0 ; int cuttingLenght = Ropes [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( Ropes [ i ] - cuttingLenght > 0 ) { System . out . print ( n - i + " ▁ " ) ; cuttingLenght = Ropes [ i ] ; singleOperation ++ ; } } if ( singleOperation == 0 ) System . out . print ( "0" ) ; } public static void main ( String [ ] arg ) { int [ ] Ropes = { 5 , 1 , 1 , 2 , 3 , 5 } ; int n = Ropes . length ; cuttringRopes ( Ropes , n ) ; } }