Solution to Min-Perimeter-Rectangle by codility

26 Jan

Question: http://codility.com/demo/take-sample-test/min_perimeter_rectangle

Question Name: MinPerimeterRectangle

Let the length of one side be len_1, and the length of one adjacent side be len_2. For a rectangle with a constant area, the perimeter is minimized when the difference between len_1 and len_2, abs(len_1- len_2), is minimized.

3 Replies to “Solution to Min-Perimeter-Rectangle by codility

  1. Great observation! min(abs(len1,len2))! I didn’t notice it at all!
    I wonder what the time complexity of sqrt is? 🙂

  2. 100%, 100% java

Leave a Reply

Your email address will not be published.

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!