字符串处理常常用在处理服务器回传的数据、动态拼接生成html等,是前端面试的必考题。 我觉得字符串处理这种常用到的,一定要了然于心,不然用到时急急忙忙去翻手册费半天。 入正题,首先提出平常遇到的几个需求,后面我们来一步一步解决它: 需求1:根据服务器返回的json数据,动态添加元素到列表<ul> 【 ...
分类:
Web程序 时间:
2016-11-05 18:00:48
阅读次数:
263
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2016-11-05 17:28:13
阅读次数:
147
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 comple ...
分类:
编程语言 时间:
2016-11-05 15:01:33
阅读次数:
317
Straight-forward strategy.. please take care of all details - data type, assignment order etc. ...
分类:
其他好文 时间:
2016-11-05 14:31:42
阅读次数:
198
http://poj.org/problem?id=1458 用dp[i][j]表示处理到第1个字符的第i个,第二个字符的第j个时的最长LCS。 1、如果str[i] == sub[j],那么LCS长度就可以+1,是从dp[i - 1][j - 1] + 1,因为是同时捂住这两个相同的字符,看看前面 ...
分类:
其他好文 时间:
2016-11-04 23:40:36
阅读次数:
254
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title>d ...
分类:
其他好文 时间:
2016-11-04 16:35:16
阅读次数:
190
注意最长公共子串(Longest CommonSubstring)和最长公共子序列(LongestCommon Subsequence, LCS)的区别:子串(Substring)是串的一个连续的部分,子序列(Subsequence)则是从不改变序列的顺序,而从序列中去掉任意的元素而获得的新序列;更 ...
分类:
其他好文 时间:
2016-11-04 14:24:17
阅读次数:
200
Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求LCS,转移同时维护f[i][j].s为当前状态字典序最小最优解 f[n][n].s的前半部分一定是回文串的前半部分(想想就行 ...
分类:
其他好文 时间:
2016-11-04 01:41:08
阅读次数:
166
Maximum sum Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 39599 Accepted: 12370 Description Given a set of n integers: A={a1, a2,..., an} ...
分类:
其他好文 时间:
2016-11-04 01:25:01
阅读次数:
259
ComputeSVD 构建一个4×5的矩阵M: M矩阵的奇异值分解后奇异矩阵s应为: 4 0 0 0 0 0 3 0 0 0 0 0 √5 0 0 0 0 0 0 0 我们将通过ComputeSVD函数进行验证. <一> 构造RowMatrix矩阵:M scala> val M = new RowM ...
分类:
其他好文 时间:
2016-11-04 01:14:11
阅读次数:
316