You are viewing a single comment's thread. Return to all comments →
public static List maximumPerimeterTriangle(List sticks) { // Write your code here int count=0;
List<Integer> output = new ArrayList<>(); Collections.sort(sticks); Collections.reverse(sticks); for(int i=0;i<sticks.size()-2;i++) { int longest=sticks.get(i); int middle = sticks.get(i+1); int shortest = sticks.get(i+2); if(shortest+middle >longest) { output.add(shortest); output.add(middle); output.add(longest); return output; } } output.add(-1); return output; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Perimeter Triangle
You are viewing a single comment's thread. Return to all comments →
public static List maximumPerimeterTriangle(List sticks) { // Write your code here int count=0;
}