Solution to gamma2011 (Count-Palindromic-Slices) by codility

5 Feb

Question: https://codility.com/demo/take-sample-test/count_palindromic_slices Question Name: CountPalindromicSlices This task is based on the longest palindromic substring question, which has a good solution naming Manacher’s algorithm. Some explanation about the algorithm could be found here (English) and here (Chinese).

Solution to Array-Inversion-Count by codility

4 Feb

Question: https://codility.com/demo/take-sample-test/array_inversion_count Question Name: ArrayInversionCount

UPDATE on July 18, 2014: Thanks to @Andrew, there is another solution with Binary Indexed Tree. UPDATE on October 8, 2014: Thanks to @Piotrek Martynowicz, there was a bug for the statement: “computes the … Read More »

Solution to omega2013 (Falling-Disks) by codility

4 Feb

Question: https://codility.com/demo/take-sample-test/falling_disks Question Name: omega2013 or FallingDisks

Solution to Equi by codility

2 Feb

Question: https://codility.com/demo/take-sample-test/equi Question Name: Equi The expected worst-case space complexity could be less than required.

Solution to Tree-Height by codility

29 Jan

Question: https://codility.com/demo/take-sample-test/tree_height Question Name: TreeHeight Classic recursion problem.

Solution to Abs-Distinct by codility

29 Jan

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.

Solution to Binary-Gap by codility

29 Jan

Question: https://codility.com/demo/take-sample-test/binary_gap Question Name: BinaryGap

Solution to alpha2010 (Prefix-Set) by codility

29 Jan

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 »

Solution to Count-Semiprimes by codility

28 Jan

Question: https://codility.com/demo/take-sample-test/count_semiprimes Question Name: CountSemiprimes