1. Longest Increasing Subsequence (LIS) problem

unsorted array, calculate out the maximum length of subsequence with non-decreasing order.

lis[i] = lis[j] + 1 if arr[i] > arr[j]; lis[i] is the lis with arr[i] as the last element. so to get the maximum for the whole array, we should iterate the array and find out the max(lis[i])

complexity: O(n^2)

better algorithm: O(n logn): http://en.wikipedia.org/wiki/Longest_increasing_subsequence#Efficient_algorithms

2. Longest common subsequence

f[i][j] =  f[i-1][j-1]+1 if s1[i-1] == s2[j-1]

max(f[i-1][j], f[i][j-1]) else

3. edit distance

f[i][j] = f[i-1][j-1] if f[i-1] == f[j-1];

min(f[i-1][j], min(f[i][j-1], f[i-1][j-1])) + 1;

4. coin change

N cents, infinitely supply S = {S1, S2, ... Sm}, how many way to change it?

f[i][j] = f[i-s[j]][j] + f[i][j-1], i: the cents, j: using 0 to j Sj to change it.

5. matrix chain multiplication

for (L = 2; L < n; L++) {  // L is the chain length

  for (int i = 1; i <= n-L+1; i++) {

    j = i+L-1;

    m[i][j] = INT_MAX;

    for (int k = i; k <= j-1; k++) {

      q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];

      m[i][j] = min(m[i][j], q);

    }

  }

}

return m[1][n-1];

最新文章

  1. TeamCity : 安装 Server
  2. js的touch事件的实际引用
  3. CodeForces 209C Trails and Glades
  4. 【BZOJ】1513: [POI2006]Tet-Tetris 3D
  5. img test
  6. Java 实现组合(Composite)模式
  7. 使用Protel99 SE 拼板的详细图解(新加队列粘贴方法)
  8. switch实现一个两数的运算
  9. python入门基础
  10. Mysql B+Tree原理
  11. 创建ajax的步骤
  12. Vue 错误记录:Cannot read property &#39;beforeRouteEnter&#39; of undefined
  13. BZOJ1969 航线规划
  14. windows 模拟用户会话创建进程
  15. CentOS 配置Tomcat服务脚本
  16. Codeforces 946D Timetable(预处理+分组背包)
  17. 使用Bus.js进行兄弟(非父子)组件通信
  18. Elasticsearch(9):使用Logstash-input-jdbc同步数据库中的数
  19. css贝塞尔曲线模仿饿了么购物车小球动画
  20. [LeetCode] string整体做hash key,窗口思想复杂度O(n)。附来自LeetCode的4例题(标题有字数限制,写不下所有例题题目 T.T)

热门文章

  1. 七天学会ASP.NET MVC (二)——ASP.NET MVC 数据传递 【转】
  2. Vbs脚本经典教材
  3. BZOJ 1878 SDOI2009 HH的项链 树状数组/莫队算法
  4. 【Python数据分析】IPython快捷键
  5. c# 访问Mysql
  6. SAS学习经验总结分享:篇四—SQL过程
  7. C# 字节数组拼接的速度实验(Array.copy(),Buffer.BlockCopy(),Contact())
  8. Ubuntu12安装RobotFramework
  9. flash插件使用外部数据的方法
  10. Bootstrap学习速查表(三) 表单