function convert(rows){ function exists(rows, parentId){ for(var i=0; i<rows.length; i++){ if (rows[i].id == parentId) return true; } return false; } var nodes = []; // get the top level nodes for(var i=0; i<rows.length; i++){ var row = rows[i]; if…
文章出处:http://www.cnblogs.com/snowberg/archive/2011/10/21/2468588.html 3 What is a Suffix Tree Suffix tree, 或 后缀树 ,是一种相当神奇的数据结构,它包含了字符串中的大量信息,能够用于解决很多复杂的字符串问题 —— 事实上,基本上目前为止俺遇到过的所有与字符串有关的问题都可以通过它解决. 我们以字符串 MISSISSIPPI 为例,先列出它所有的后缀: 1. MISSISSIPPI 2…
Here is a difficulty and frequency distribution chart for each problem (which I got from the Internet and is very useful). Dynamic Programming Edit Distance Maximum Subarray Minimum Path Sum Unique Paths Unique Paths II Longest Palindromic Substring…