Eric Yuan's Blog

Perstando et Praestando

  • About Me

LeetCode

Hanafuda

September 1, 2014 / 6 Comments

I watched an anime called Summer Wars (サマーウォーズ/夏日大作战) last month, I was impressed by the Hanafuda card game in it. Occasionally I found Hanafuda in Kinokuniya the Japanese book store yesterday, I bought one. I’m learning to play Hanafuda and thinking if I can make a simple Hanafuda AI. It would be great since I’m preparing … [Read more…]

Posted in: Something else Tagged: LeetCode, Summer Wars

[LeetCode] Trapping Rain Water

January 26, 2014 / Leave a Comment

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: Algorithm, Dynamic Programming, LeetCode, SOLUTION

[LeetCode] Jump Game II

January 19, 2014 / 1 Comment

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 … [Read more…]

Posted in: Algorithm, LeetCode Tagged: Algorithm, LeetCode

[LeetCode] Best Time to Buy and Sell Stock III

January 18, 2014 / Leave a Comment

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 … [Read more…]

Posted in: Algorithm, Dynamic Programming, LeetCode Tagged: Algorithm, DP, Dynamic Programming, LeetCode

[LeetCode] Edit Distance

January 16, 2014 / Leave a Comment

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 … [Read more…]

Posted in: Algorithm, Dynamic Programming, LeetCode Tagged: Algorithm, Dynamic Programming, LeetCode

[LeetCode] Largest Rectangle in Histogram

January 15, 2014 / 1 Comment

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: Algorithm, LeetCode

[LeetCode] Word Break

January 15, 2014 / Leave a Comment

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: Algorithm, Dynamic Programming, LeetCode

[LeetCode] Minimum Window Substring

January 14, 2014 / Leave a Comment

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, … [Read more…]

Posted in: Algorithm, LeetCode Tagged: Algorithm, LeetCode

[LeetCode] Surrounded Regions

January 14, 2014 / Leave a Comment

Given a 2D board containing ‘X’ and ‘O’, capture all regions surrounded by ‘X’. A region is captured by flipping all ‘O’s into ‘X’s in that surrounded region . The trick is to search from the edge, but not inside the whole region. These 4 images show how the trick works.

Posted in: Algorithm, LeetCode Tagged: Algorithm, LeetCode

[LeetCode] Max Points on a Line

January 14, 2014 / 2 Comments

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. At first my thought was, given 2 points, we can get a line which connect these two points, and this line can be designated as: y =  k x + b Assume one of the two points is … [Read more…]

Posted in: Algorithm, LeetCode Tagged: Algorithm, LeetCode

Pages

  • About Me

Categories

  • Algorithm
  • Deep Learning
  • Dynamic Programming
  • Graphics
  • LeetCode
  • Machine Learning
  • Machine Reading Comprehension
  • Maths
  • NLP
  • OpenCV
  • Something else
  • Twaddle
  • Uncategorized
  • Vision

Archives

  • July 2016
  • August 2015
  • June 2015
  • April 2015
  • March 2015
  • October 2014
  • September 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • November 2013
  • October 2013
  • September 2013

Copyright © 2019 Eric Yuan's Blog.

Me WordPress Theme by themehall.com