Monthly Archives: January 2014

Linear Regression study notes

I chose Prof. Yann LeCun‘s Deep Learning as one of my three attending courses this semester, because that I have no background of machine learning, so I also viewing Prof. Andrew Ng’s Machine Learning lectures online recent days. At the beginning of the lectures, it was about linear regression. I heard about some simple linear regression […]

Posted in Algorithm, Machine Learning | Tagged , , , , , | 3 Responses

[LeetCode] Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.

Posted in Algorithm, Dynamic Programming, LeetCode | Tagged , , , | Leave a comment

Phong Shading

  Phong shading is actually kind of interpolation method for 3D graphics surface shading, it was developed by Bùi Tường Phong. Rather than Phong shading, I want to talk about Phong reflection model here. As Phong reflection model says, we can split light into three separate parts: Ambient, Diffuse, and Specular, and in the reverse way, we […]

Posted in Graphics | Tagged , , , , | Leave a comment

[LeetCode] Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. Actually I got no trick for this problem, I just find […]

Posted in Algorithm, LeetCode | Tagged , | 1 Response

A Simple QR Code Scanner [part 1]

QR Code is kind of matrix barcode, it is recently very popular because of its fast read speed and big storage capacity, we can see it everywhere, Jeky even wanted to tattoo one on his body. A QR code makes up by  black square dots and white square grid, black dots arrange in white background, […]

Posted in Algorithm, OpenCV | Tagged , , , , | 9 Responses

[LeetCode] Best Time to Buy and Sell Stock III

Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). Find the maximum […]

Posted in Algorithm, Dynamic Programming, LeetCode | Tagged , , , | Leave a comment

[LeetCode] Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a character b) Delete a character c) Replace a character Find minimum number of steps, then it must be a Dynamic Programming problem. Only […]

Posted in Algorithm, Dynamic Programming, LeetCode | Tagged , , | Leave a comment

[LeetCode] Largest Rectangle in Histogram

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.

Posted in Algorithm, LeetCode | Tagged , | 1 Response

[LeetCode] Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = “leetcode”, dict = [“leet”, “code”]. Return true because “leetcode” can be segmented as “leet code”. Most of problems that return a bool value or int value (amount) in LeetCode can be solved using Dynamic Programming.

Posted in Algorithm, Dynamic Programming, LeetCode | Tagged , , | Leave a comment

[LeetCode] Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = “ADOBECODEBANC” T = “ABC” Minimum window is “BANC”. The basic idea is to find a window which contain all characters in T first, this window does not necessary to be optimize, […]

Posted in Algorithm, LeetCode | Tagged , | Leave a comment