You are viewing a single comment's thread. Return to all comments →
Consider the test case 5 4 4 2 2 8 After sorting 2 2 4 4 5 8 We cut the sticks of length 2 ,then we will be left with only 4 sticks
Initially sticks --> 2 2 4 4 5 8 (6) length 2 will be cut --> 2 2 3 6 (4) length 2 will be cut --> 1 3 (2) length 1 will be cut --> 2 (1) length 2 will be cut --> 0 (0)
This can be taken as eliminating equal length sticks at each round ..so does the below statement
if(arr[i]!=arr[i+1]) System.out.println(n-(i+1));
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
Consider the test case 5 4 4 2 2 8 After sorting 2 2 4 4 5 8 We cut the sticks of length 2 ,then we will be left with only 4 sticks
This can be taken as eliminating equal length sticks at each round ..so does the below statement