题目大意:用m个机器人去遍历有n个节点的有根树,边权代表一个机器人通过这条边的代价,求最小代价。 题目分析:定义状态dp(root,k)表示最终遍历完成后以root为根节点的子树中有k个机器人时产生的总代价。则状态转移方程为: dp(root,k)=min(dp(root,k),dp(son,j)+ ...
分类:
Web程序 时间:
2016-04-04 10:17:49
阅读次数:
208
Given a string, find the length of the longest substring T that contains at most k distinct characters. For example, Given s = “eceba” and k = 2, T is ...
分类:
其他好文 时间:
2016-04-04 09:11:32
阅读次数:
290
本文转自:http://www.cnblogs.com/TenosDoIt/p/3675788.html 题目链接 Given a string S, find the longest palindromic substring in S. You may assume that the maxim ...
分类:
其他好文 时间:
2016-04-03 22:05:20
阅读次数:
260
题目描述: Given an array of integers, every element appears three times except for one. Find that single one. 解题思路: 具体参考Detailed explanation and generaliz ...
分类:
编程语言 时间:
2016-04-03 18:59:37
阅读次数:
198
#find the nearest point in two dimensions#1 first if there are only two points, then calculate the distance directly#2 if there are three points, get ...
分类:
其他好文 时间:
2016-04-03 17:35:37
阅读次数:
251
bash下有grep命令,与之相对应的是cmd下的find命令。 /i 不区分大小写。与grep一致 /v 过滤掉匹配的行。与grep一致 /n 显示行号。与grep一致 /c 仅显示匹配的行数。与grep一致 find的局限,不支持正则表达式 还有一个工具findstr,功能比find强大,选项亦 ...
分类:
其他好文 时间:
2016-04-03 17:29:37
阅读次数:
153
1. Description Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, ...
分类:
其他好文 时间:
2016-04-03 15:59:40
阅读次数:
189
原题链接在这里:http://www.lintcode.com/en/problem/longest-common-subsequence/ 题目: Given two strings, find the longest common subsequence (LCS). Your code sho ...
分类:
其他好文 时间:
2016-04-03 14:39:10
阅读次数:
173
Xcode升级7.3之后,出现了种种问题,虽然代码提示更加人性化了,但是导入框架后,出现了类没有提示等相关问题,一定程度上降低了开发效率.一怒之下装回7.2版本,却在安装后发现新建playground界面以及打开playground文件时一直弹框报错,错误提示如下: 解决办法: 输入这两条命令后,重 ...
分类:
其他好文 时间:
2016-04-03 14:36:48
阅读次数:
143
原题链接在这里:http://www.lintcode.com/en/problem/longest-common-substring/# 题目: Given two strings, find the longest common substring. Return the length of i ...
分类:
其他好文 时间:
2016-04-03 14:27:29
阅读次数:
225