## Solution to House Robber by LeetCode

18 Jun

Question: https://leetcode.com/problems/house-robber/ Question Name: House Robber Simple DP problem. If you want, you could improve the space complexity to O(1) with bookkeeping (the second previous house, the previous house, and the current house).

## Solution to Number of 1 Bits by LeetCode

1 Jun

Question: https://leetcode.com/problems/number-of-1-bits/ Question Name: Number of 1 Bits The key is how to find and remove the last 1-bit.

## Solution to Reverse Bits by LeetCode

1 Jun

Question: https://leetcode.com/problems/reverse-bits/ Question Name: Reverse Bits Exactly same challege from Elements of Programming Interviews.

## Solution to Rotate Array by LeetCode

28 May

Question: https://leetcode.com/problems/rotate-array/ Question Name: Rotate Array Classic Doug McIlroy’s Handwaving. It is very similar with some previous question.

## Solution to Best Time to Buy and Sell Stock IV by LeetCode

25 May

Question: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/ Question Name: Best Time to Buy and Sell Stock IV Thanks to genius solution from @yishiluo.

## Solution to Repeated DNA Sequences by LeetCode

29 Apr

Question: https://leetcode.com/problems/repeated-dna-sequences/ Question Name: Repeated DNA Sequences Simple brute force solution works.

## Solution to Largest Number by LeetCode

29 Apr

Question: https://leetcode.com/problems/largest-number/ Question Name: Largest Number Conver the input numbers into strings. And then sort the strings according to special rule.

However, if you prefer a Python3 solution:

## Solution to Dungeon Game by LeetCode

27 Apr

Question: https://leetcode.com/problems/dungeon-game/ Question Name: Dungeon Game The challenge is a DP question. Let minHPFromHere be a 2D matrix with the size of input dungeon game. minHPFromHere[i][j] is the minimum HP to rescue the princess, if the input[i][j] is the initial … Read More »

## Solution to Binary Search Tree Iterator by LeetCode

24 Apr

Question: https://leetcode.com/problems/binary-search-tree-iterator/ Question Name: Binary Search Tree Iterator The challenge is a variant of the iterative in-order traversal of BST. However, yield in python is much much better in implementing iterator, right?

## Solution to Factorial Trailing Zeroes by LeetCode

24 Apr

Question: https://leetcode.com/problems/factorial-trailing-zeroes/ Question Name: Factorial Trailing Zeroes I firstly saw this question on CTCI. The key points of the solution are: Every interger could be represented as (2^i)*(5^j)*x, where i, j >= 0 and x cannot be evenly divided by … Read More »