Solution to Rectangle-Builder-Greater-Area by codility

20 Nov

Question: https://codility.com/demo/take-sample-test/rectangle_builder_greater_area/ Question Name: Rectangle-Builder-Greater-Area or RectangleBuilderGreaterArea This key is the binary search.

Solution to Dwarfs-Rafting by codility

19 Nov

Question: https://codility.com/demo/take-sample-test/dwarfs_rafting/ Question Name: Dwarfs-Rafting or DwarfsRafting Need some simple mathematical knowledge. The code is unnecessarily long. A 2-d array is better to write much shorter code. However, I keep the long version for better readability.

Solution to Slalom-Skiing by codility

22 Oct

Question: https://codility.com/programmers/lessons/90-tasks_from_indeed_prime_2015_challenge/slalom_skiing/ Question Name: Slalom-Skiing or SlalomSkiing This is a wonderful variant of longest increasing subsequence. Because the longest increasing subsequence is a very classic question withe O(NlogN) solution, the key point to solve this question is to covert its original form … Read More »

Solution to Flood-Depth by codility

25 Sep

Question: https://codility.com/demo/take-sample-test/flood_depth/ Question Name: Flood-Depth or FloodDepth This is a variant of Trapping Rain Water by LeetCode. The undergoing concept is the same. However, the implementation is a bit different.

Solution to Longest-Password by codility

22 Sep

Question: https://codility.com/demo/take-sample-test/longest_password/ Question Name: Longest-Password or LongestPassword The solution could be more Pythonic with some additional space.

Solution to Sql-Sum by codility

21 Sep

Question: https://codility.com/demo/take-sample-test/sql_sum/ Question Name: Sql-Sum or SqlSum This question is too easy to be a serious training lesson. Most likely, it’s a live test for SQL challenges on Codility.com. The following solution works in both PostgreSQL and SQLite.

Solution to Cyclic-Rotation by codility

9 Feb

Question: https://codility.com/demo/take-sample-test/cyclic_rotation/ Question Name: Cyclic-Rotation or CyclicRotation With Python’s syntactic sugar, the solution is pretty short.

Well, kind of too easy. Let’s try a C++ solution to demo the details better. Thanks to @micropentium6, the original C++ solution is … Read More »

Solution to Polygon-Concavity-Index by codility

18 Oct

Question: https://codility.com/demo/take-sample-test/polygon_concavity_index/ Question Name: Polygon-Concavity-Index or PolygonConcavityIndex Thanks to Robert Sedgewick, the Youtube video (Algorithms, Part I – Convex Hull) tells everything about this problem.

Solution to Odd-Occurrences-In-Array by codility

18 Sep

Question: https://codility.com/programmers/task/odd_occurrences_in_array Question Name: Odd-Occurrences-In-Array or OddOccurrencesInArray This question is completely the same as the Perm-Missing-Elem by codility. The comment from Kim is very helpful.

Solution to Number-Solitaire by codility

6 Sep

Question: https://codility.com/demo/take-sample-test/number_solitaire/ Question Name: Number-Solitaire or NumberSolitaire The key point is: to achieve the position i, we can only come from the positions i-6, i-5, i-4, i-3, i-2, and i-1.