You are viewing a single comment's thread. Return to all comments →
Java:
public static List<Integer> maximumPerimeterTriangle(List<Integer> sticks) { Collections.sort(sticks); int n = sticks.size(); for (int i = n - 1; i >= 2; i--) { int a = sticks.get(i - 2); int b = sticks.get(i - 1); int c = sticks.get(i); if (c < a + b) { return Arrays.asList(a, b, c); } } return Arrays.asList(-1); }
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 →
Java: