## Solution to Max-Double-Slice-Sum by codility

25 Jan

Question: http://codility.com/demo/take-sample-test/max_double_slice_sum Question Name: MaxDoubleSliceSum A variant of the classic maximum subarray problem. We should travel the array twice. For the first travel, we compute and record the maximum sub-array sum, which ends at each position. At the second reverse … Read More »

24 Jan

## Solution to Dominator by codility

24 Jan

Question: http://codility.com/demo/take-sample-test/dominator Question Name: Dominator Same question in the introduction pdf.

## Solution to Fish by codility

23 Jan

Question: http://codility.com/demo/take-sample-test/fish Question Name: Fish UPDATE 03-14-2014: “downstream_count” is a redundant variable. It could be replaced with len(downstream) safely. (Thanks to the reminder from Max)

## Solution to sigma2012 (Stone-Wall) by codility

23 Jan

Question: http://codility.com/demo/take-sample-test/stone_wall Question Name: sigma2012 or StoneWall

## Solution to Nesting by codility

22 Jan

Question: http://codility.com/demo/take-sample-test/nesting Question Name: Nesting This question is nearly the same as the previous one, but does not need a stack.

## Solution to Brackets by codility

22 Jan

Question: http://codility.com/demo/take-sample-test/brackets Question Name: Brackets Classic application of stacks.

UPDATE (2016-07-19): Much appreciate Jeffrey’s comment and suggestion: I’m surprised so few people didn’t do a simple modulo at the start to check whether there is an even number of chars. … Read More »

## Solution to beta2010 (Number-Of-Disc-Intersections) by codility

22 Jan

Question: http://codility.com/demo/take-sample-test/number_of_disc_intersections Question Name: beta2010 or NumberOfDiscIntersections Interesting question. Does geometry matter here? Not much.

UPDATE on 2015/10/16: here is some pseudo-code to help you understand. Firstly, we convert the 2D problem into 1D. Because all the circles’ center … Read More »

## Solution to Triangle by codility

21 Jan

Question: http://codility.com/demo/take-sample-test/triangle Question Name: Triangle Update: we need two parts to prove our solution. On one hand, there is no false triangular. Since the array is sorted, we already know A[index] < = A[index+1] <= A[index+2], and all values are … Read More »

## Solution to Max-Product-Of-Three by codility

21 Jan

Question: http://codility.com/demo/take-sample-test/max_product_of_three Question Name: MaxProductOfThree An small trap: multiplying two negatives makes a positive number.

UPDATE on 03-02-2015: Thanks to @Julian, there is an O(N) solution. We sort the input in the original solution, because we want the two … Read More »