## 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.

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 House Robber II by LeetCode

3 Feb

Question: https://leetcode.com/problems/house-robber-ii/ Question Name: House Robber II This is a variant of House Robber. We need to apply the previous solution to two sub-arrays and return the maximum of the two results: 1. Do not use the first element, and … Read More »

## Solution to Word Search II by LeetCode

1 Feb

Question: https://leetcode.com/problems/word-search-ii/ Question Name: Word Search II In general, this is a question with DFS/BFS of graph. Additionally, we need some optimizations: Use prefix tree to terminate the search early; Remove the found word in the prefix tree; Use bigrams … Read More »

## Solution to Add and Search Word – Data Structure Design by LeetCode

8 Jan

Question: https://leetcode.com/problems/add-and-search-word-data-structure-design/ Question Name: Add and Search Word – Data Structure Design This is a variant of prefix tree (trie).

## Solution to Course Schedule II by LeetCode

3 Jan

Question: https://leetcode.com/problems/course-schedule-ii/ Question Name: Course Schedule II

## Solution to Minimum Size Subarray Sum by LeetCode

1 Jan

Question: https://leetcode.com/problems/minimum-size-subarray-sum/ Question Name: Minimum Size Subarray Sum This question is very similar with Longest Substring Without Repeating Characters and Minimum Window Substring.

## Solution to Implement Trie (Prefix Tree) by LeetCode

1 Jan

Question: https://leetcode.com/problems/implement-trie-prefix-tree/ Question Name: Implement Trie (Prefix Tree) Not a full implementation. The delete function is not required.

## Solution to Course Schedule by LeetCode

22 Dec

Question: https://leetcode.com/problems/course-schedule/ Question Name: Course Schedule

## 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.