Solution to Abs-Distinct by codility
Question: https://codility.com/demo/take-sample-test/abs_distinct Question Name: AbsDistinct In the original requirement, expected worst-case space complexity is O(N). But actually, O(1) is enought.
C code. C code run. Run code run… please!
Question: https://codility.com/demo/take-sample-test/abs_distinct Question Name: AbsDistinct In the original requirement, expected worst-case space complexity is O(N). But actually, O(1) is enought.
Question: https://codility.com/demo/take-sample-test/binary_gap Question Name: BinaryGap
Question: https://codility.com/demo/take-sample-test/prefix_set Question Name: alpha2010 or PrefixSet At the first glance, I think the set of Python is the best choice. Actually, the set solution passed all the test, and got 100/100 grade.
BUT, acording to the time complexity … Read More »
Question: https://codility.com/demo/take-sample-test/count_semiprimes Question Name: CountSemiprimes
Question: https://codility.com/demo/take-sample-test/count_non_divisible Question Name: CountNonDivisible
Question: https://codility.com/demo/take-sample-test/flags Question Name: boron2013 or Flags The official solution is here. UPDATE 2014-10-02: thanks to Piotrek Martynowicz, a bug is found and fixed.
Question: http://codility.com/demo/take-sample-test/peaks Question Name: Peaks UPDATE on July 18th 2015: Many thanks to @Antonio Correia (https://34.145.67.234/2014/solution-to-peaks-by-codility/#comment-11725) !!! @Antonio Correia found a huge bug in my solution, even though it passed the codility.com. The bug has been fixed.
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, … Read More »
Question: http://codility.com/demo/take-sample-test/max_slice_sum Question Name: MaxSliceSum The classic maximum subarray problem. It should be the very first question in this lesson.
Question: http://codility.com/demo/take-sample-test/max_profit Question Name: MaxProfit For this question, we have to travel from the last element to the first one.