We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticList<Integer>maximumPerimeterTriangle(List<Integer>sticks){// Write your code hereList<Integer>ans=newArrayList<>();intx=-1;Collections.sort(sticks);for(inti=0;i<sticks.size()-2;i++)if(sticks.get(i)+sticks.get(i+1)>sticks.get(i+2))x=i;if(x==-1){ans.add(-1);returnans;}else{ans.add(sticks.get(x));ans.add(sticks.get(x+1));ans.add(sticks.get(x+2));returnans;}}
Cookie support is required to access HackerRank
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 →