## Solution to psi2012 (Wire-Burnouts) by codility

28 Apr

Question: https://codility.com/demo/take-sample-test/wire_burnouts Question Name: psi2012 or Wire-Burnouts or WireBurnouts A good application of weighted quick union algorithm.

## Solution to Min-Abs-Sum-Of-Two by codility

21 Apr

Question: https://codility.com/demo/take-sample-test/min_abs_sum_of_two Question Name: Min-Abs-Sum-Of-Two or MinAbsSumOfTwo There are two O(nlogn) solutions for this question. Both solutions have the same overall time complexity and space complexity. And both solutions need to sort the array in non-decreasing order first. The first … Read More »

## Solution to Count-Distinct-Slices by codility

17 Apr

Question: https://codility.com/demo/take-sample-test/count_distinct_slices Question Name: Count-Distinct-Slices or CountDistinctSlices

## Solution to Count-Triangles by codility

17 Apr

Question: https://codility.com/demo/take-sample-test/count_triangles Question Name: Count-Triangles or CountTriangles This problem is nearly the same as the exercise in presentation of lesson 13. Update on May 24, 2014: Thanks to @Adam. Fix a bug, which lower the performance.

## Solution to Count-Div by codility

16 Apr

Question: https://codility.com/demo/take-sample-test/count_div Question Name: Count-Div or CountDiv It is completely a mathematic question. Not qualified for a 2-star problem.

## Solution to Nailing-Planks by codility

8 Apr

Question: https://codility.com/demo/take-sample-test/nailing_planks Question Name: Nailing Planks or NailingPlanks This question is designed to be solved with binary search method (BUT there is a better solution! It is updated at the end of this post.). And the binary solution is as … Read More »

## Solution to Min-Max-Division by codility

6 Apr

Question: https://codility.com/demo/take-sample-test/min_max_division Question Name: Min-Max-Division or MinMaxDivision Logically, it seems to be similar with the boron2013 (Flags) challenge by Codility. And the following is my Python solution. UPDATE – 2014/09/19: thanks to Martin Kysel. The function signature is changed to: … Read More »

## Solution to Distinct by codility

18 Mar

Question: https://codility.com/demo/take-sample-test/distinct Question Name: Distinct In this question, the expected worst-case time complexity is O(N*log(N)). Thus the designed, or says official, solution would be sort the input and travel them. This solution is practically good. And it is shown as … Read More »

## Solution to helium2013 (Find-Three) by codility

17 Mar

Question: https://codility.com/demo/take-sample-test/find_three Question Name: helium2013 or Find-Three or FindThree For this question, we have two similar but different ways to solve it. The first solution uses the border array algorithm. And the other one is with the Z algorithm for … Read More »

## Solution to Fib-Frog by codility

11 Mar

Question: https://codility.com/demo/take-sample-test/fib_frog Question Name: Fib-Frog or FibFrog To solve this question, we are using the Breadth First Search with pruning. For a game with N intermediate nodes, the count of Fibonacci numbers, to say CF, is proportional to log(N) [Wikipedia]. … Read More »