Solution to Contains Duplicate by LeetCode

20 Aug
Question: https://leetcode.com/problems/contains-duplicate/ Question Name: Contains Duplicate In general, I found two solutions. The first solution is using hash set: [crayon-57ba46f486517723493398/] The second solution is using sorting. We could sort the input and check each pair of adjacent items. Or we could early...
Read more »

Solution to Shortest Palindrome by LeetCode

8 Jun
Question: https://leetcode.com/problems/shortest-palindrome/ Question Name: Shortest Palindrome This is a variant of Longest Palindromic Substring. The key point is to convert the original question as following: 1. Shortest Palindrome by adding any characters in the head.  Therefore the original string “original” is going...
Read more »

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. [crayon-57ba46f48984d962850208/] 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 »