Category Archives: Computer Science

Triangle

http://oj.leetcode.com/problems/triangle/ The problem statement is deceptive by mentioning path from “top” to “bottom”. I was fooled at first and tried to compare all the ways from the top to the bottoms. However, it is impractical since there are O(2^(n-1)) such … Continue reading

Posted in Computer Science, LeetCode | Tagged , , , | Leave a comment

Sum Root to Leaf Numbers

http://oj.leetcode.com/problems/sum-root-to-leaf-numbers/ Another problem from Leetcode that I came up with two different solutions. The first solution idea is to get paths from root to leaves first, compute the sum later. Those paths can be easily discovered by depth first search, … Continue reading

Posted in Computer Science, LeetCode | Tagged , , , , | Leave a comment

Flatten Binary Tree

LeetCodeLink I have solved this problem weeks ago, but today I completely forgot how I had solved it. As I tried to simulate the interview, I started to think and finally came up with a solution, which is interestingly different … Continue reading

Posted in Computer Science, LeetCode | Leave a comment

Bellman-Ford’s Algorithm

Dijkstra’s algorithm is fast, but limited to non-negatively weighted graph. It also does not applicable for distributed system. Bellman-Ford’s algorithm is the solution for the two problems. It is asymptotically slower than Dijkstra’s algorithm as its complexity is O(EV). However, … Continue reading

Posted in Algorithms, Computer Science | Tagged , , , , | Leave a comment

Dijkstra’s Algorithm

2014/3/5: How stupid I was for not recognizing Dijkstra as a special case of A* without heuristic cost. It makes the algorithm much easier to understand and implement. We only need to consider vertices as states and put them to … Continue reading

Posted in Algorithms, Computer Science | Tagged , , , , , | Leave a comment

Max points on a line

I have been preparing for the coming technical interview for two weeks and Leetcode is my main source for practicing. I already solved over 80% problems, but I find it difficult to review my solution by merely looking at the … Continue reading

Posted in Computer Science, LeetCode | Tagged , | Leave a comment

Hidden Markov Model

Hidden Markov Model I will try to do 2 small projects every month. I want to start with HMMs because it is quite easy to implement and a prerequisite knowledge for understanding machine learning topics. Objective: Build a simple HMM … Continue reading

Posted in Project | Leave a comment