随笔分类 -  Algorithm

上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页

[LintCode] Binary Tree Serialization
摘要:Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back f... 阅读全文

posted @ 2015-05-25 18:16 Eason Liu 阅读(595) 评论(0) 推荐(0)

[LeetCode] Max Points on a Line
摘要:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.经过同一个点且斜率相等的直线一定是同一条直线,所以我们只要分别计算每一个点与其它点的直线的斜率,统计斜率的... 阅读全文

posted @ 2015-05-25 14:32 Eason Liu 阅读(223) 评论(0) 推荐(0)

[LeetCode] Combination Sum III
摘要:Find all possible combinations ofknumbers that add up to a numbern, given that only numbers from 1 to 9 can be used and each combination should be a u... 阅读全文

posted @ 2015-05-24 11:54 Eason Liu 阅读(1010) 评论(1) 推荐(0)

[LintCode] Coins in a Line II
摘要:There are n coins with different value in a line. Two players take turns to take one or two coins from left side until there are no more coins left. T... 阅读全文

posted @ 2015-05-23 23:47 Eason Liu 阅读(2266) 评论(0) 推荐(0)

[LeetCode] Kth Largest Element in an Array
摘要:Find thekth largest element in an unsorted array.For example,Given[3,2,1,5,6,4]and k = 2, return 5.Note:You may assume k is always valid, 1 ≤ k ≤ arra... 阅读全文

posted @ 2015-05-23 12:06 Eason Liu 阅读(4928) 评论(3) 推荐(0)

[LeetCode] Shortest Palindrome
摘要:Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can f... 阅读全文

posted @ 2015-05-22 16:41 Eason Liu 阅读(3436) 评论(0) 推荐(0)

[LeetCode] House Robber II
摘要:After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This t... 阅读全文

posted @ 2015-05-20 10:43 Eason Liu 阅读(3419) 评论(2) 推荐(0)

[LeetCode] Word Search II
摘要:Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjac... 阅读全文

posted @ 2015-05-19 11:31 Eason Liu 阅读(4649) 评论(0) 推荐(0)

[LintCode] Find Peak Element II
摘要:There is an integer matrix which has the following features:The numbers in adjacent positions are different.The matrix has n rows and m columns.For al... 阅读全文

posted @ 2015-05-17 13:03 Eason Liu 阅读(2626) 评论(3) 推荐(0)

[LintCode] k Sum
摘要:Given n distinct positive integers, integer k (k A, int k, int target) {11 // wirte your code here12 vector > dp(k + 1, vector(target... 阅读全文

posted @ 2015-05-16 17:25 Eason Liu 阅读(1089) 评论(0) 推荐(0)

[LeetCode] Add and Search Word - Data structure design
摘要:Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regu... 阅读全文

posted @ 2015-05-16 15:42 Eason Liu 阅读(305) 评论(0) 推荐(0)

[LintCode] Delete Digits
摘要:Given string A representative a positive integer which hasNdigits, remove anykdigits of the number, the remaining digits are arranged according to the... 阅读全文

posted @ 2015-05-16 12:31 Eason Liu 阅读(1537) 评论(0) 推荐(0)

[LintCode] Number of Airplanes in the Sky
摘要:Given an interval list which are flying and landing time of the flight. How many airplanes are on the sky at most?ExampleFor interval list[[1,10],[2,3... 阅读全文

posted @ 2015-05-14 22:19 Eason Liu 阅读(2622) 评论(1) 推荐(2)

[LintCode] Subarray Sum Closest
摘要:Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.ExampleGiven [-3, 1, 1, -3, 5... 阅读全文

posted @ 2015-05-14 21:23 Eason Liu 阅读(1120) 评论(0) 推荐(0)

[LeetCode] Course Schedule II
摘要:There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to firs... 阅读全文

posted @ 2015-05-14 00:11 Eason Liu 阅读(1388) 评论(0) 推荐(0)

[LeetCode] Minimum Size Subarray Sum
摘要:Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 i... 阅读全文

posted @ 2015-05-13 16:17 Eason Liu 阅读(442) 评论(0) 推荐(0)

[LeetCode] Implement Trie (Prefix Tree)
摘要:Implement a trie withinsert,search, andstartsWithmethods.Note:You may assume that all inputs are consist of lowercase lettersa-z.实现字典树,没啥好说的。 1 class ... 阅读全文

posted @ 2015-05-08 18:17 Eason Liu 阅读(1673) 评论(0) 推荐(0)

[Leetcode] Course Schedule
摘要:There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to firs... 阅读全文

posted @ 2015-05-06 22:22 Eason Liu 阅读(3275) 评论(0) 推荐(0)

[hihoCoder] 博弈游戏·Nim游戏
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述今天我们要认识一对新朋友,Alice与Bob。Alice与Bob总是在进行各种各样的比试,今天他们在玩一个取石子的游戏。在这个游戏中,Alice和Bob放置了N堆不同的石子,编号1..N,第i堆中有A[i]个石子。每一次行动,Al... 阅读全文

posted @ 2015-05-02 21:27 Eason Liu 阅读(3722) 评论(1) 推荐(1)

[hihoCoder] #1055 : 刷油漆
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述上回说到,小Ho有着一棵灰常好玩的树玩具!这棵树玩具是由N个小球和N-1根木棍拼凑而成,这N个小球都被小Ho标上了不同的数字,并且这些数字都是处于1..N的范围之内,每根木棍都连接着两个不同的小球,并且保证任意两个小球间都不存在两... 阅读全文

posted @ 2015-04-30 14:23 Eason Liu 阅读(775) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页