Solution to Merge Sorted Array by LeetCode

26 Jun

Question: https://oj.leetcode.com/problems/merge-sorted-array/ Question Name: Merge Sorted Array

Solution to Gray Code by LeetCode

26 Jun

Question: https://oj.leetcode.com/problems/gray-code/ Question Name: Gray Code At the beginning, I have no idea other than brute force. But thanks to Wikipedia, the perfect solution is found.

Solution to Partition List by LeetCode

26 Jun

Question: https://oj.leetcode.com/problems/partition-list/ Question Name: Partition List

Solution to Scramble String by LeetCode

26 Jun

Question: https://oj.leetcode.com/problems/scramble-string/ Question Name: Scramble String

Solution to Maximal Rectangle by LeetCode

24 Jun

Question: https://oj.leetcode.com/problems/maximal-rectangle/ Question Name: Maximal Rectangle

Solution to Remove Duplicates from Sorted List II by LeetCode

23 Jun

Question: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ Question Name: Remove Duplicates from Sorted List II

Solution to Remove Duplicates from Sorted List by LeetCode

23 Jun

Question: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/ Question Name: Remove Duplicates from Sorted List

Solution to Largest Rectangle in Histogram by LeetCode

23 Jun

Question: https://oj.leetcode.com/problems/largest-rectangle-in-histogram/ Question name: Largest Rectangle in Histogram

Update on 2014-06-24: Thanks to optimization, the previous solution passed all the tests. But when I met with the question “Maximal Rectangle”, I realized the previous one is not the designed … Read More »

Solution to Remove Duplicates from Sorted Array II by LeetCode

20 Jun

Question: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ Question Name: Remove Duplicates from Sorted Array II The second previous element might be overwritten in the last round.

Well, inspired by http://www.mitbbs.com/article_t/JobHunting/32770131.html, there is a better and more generic solution as:

With the parameter M … Read More »

Solution to Search in Rotated Sorted Array II by LeetCode

20 Jun

Question: https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/ Question Name: Search in Rotated Sorted Array II I did not notice, there is no duplicate in Search in Rotated Sorted Array. SO I’ve done this in that question.