动态规划基本题目,longest incresing sequence,找出序列中的最长递增子序列;

例如给出序列{8,3,5,2,4,9,7,11},

其中最长递增子序列为{3,5,9,11}或{3,5,7,11}或{3,4,9,11}或{3,4,7,11},子序列按元素递增,序列长度都为4;

子问题:第i处的最长子序列问题

定义问题:

阶段:后序,到第i项为阶段i;

状态:到i处的最长子序列为dp[i];

决策:dp[i]=max{dp[j]}+1,i<j<=n,a[i]<a[j]

有了上述公式既可以建立动态表dp;

Array 8 3 5 2 4 9 7 11
dp 3 4 3 4 3 2 2 1

代码之后给出

longest incresing sequence的更多相关文章

  1. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

  2. [LeetCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  3. Binary Tree Longest Consecutive Sequence

    Given a binary tree, find the length of the longest consecutive sequence path (连续的路径,不是从小到大). The pa ...

  4. 128. Longest Consecutive Sequence(leetcode)

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  5. ACM Longest Repeated Sequence

    Description You are given a sequence of integers, A = a1, a2, ... an. A consecutive subsequence of A ...

  6. [LintCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. H ...

  7. LeetCode Binary Tree Longest Consecutive Sequence

    原题链接在这里:https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/ 题目: Given a binary t ...

  8. 24. Longest Consecutive Sequence

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

  9. 【leetcode】Longest Consecutive Sequence

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

随机推荐

  1. WEB ICON 的探讨

    一般考虑到webicon 就是cssSprite和自定义font:本文基于下述而总结和进行分析,如有笔误有望指出,谢谢 在线教程:用字体在网页中画ICON图标 http://www.imooc.com ...

  2. Web开发在线工具

    JSON: JSON格式化工具 JSON检验并格式化工具 专为Web开发者准备的 63个免费在线工具

  3. [LeetCode]题解(python):026-Remove Duplicates from Sorted Array

    题目来源: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题意分析: 给定一个排好序的数组,去除重复的数,返回新 ...

  4. TortoiseGit 自动登录

    在环境变量里添加Home=%USERPROFILE% 在运行中打开%Home% 在打开目录中新建文件_netrc,并保存以下内容 machine git.oschina.net login usern ...

  5. BZOJ 1609: [Usaco2008 Feb]Eating Together麻烦的聚餐

    1609: [Usaco2008 Feb]Eating Together麻烦的聚餐 Description 为了避免餐厅过分拥挤,FJ要求奶牛们分3批就餐.每天晚饭前,奶牛们都会在餐厅前排队入内,按F ...

  6. Average(模拟)

      Average Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Tota ...

  7. android 实现蓝牙自动配对连接

    BluetoothConnectActivityReceiver.java:监听蓝牙配对的广播 代码: package com.imte.Broadcast; import com.imte.util ...

  8. 在Update Panel 控件里面添加 File Upload 控件 上传文件

    Detail Information:http://www.codeproject.com/Articles/482800/FileplusUploadplusinplusUpdateplusPane ...

  9. [Swust OJ 85]--单向公路(BFS)

    题目链接:http://acm.swust.edu.cn/problem/0085/ Time limit(ms): 5000 Memory limit(kb): 65535   Descriptio ...

  10. [转] Chrome 控制台不完全指南

    转自: http://www.cnblogs.com/Wayou/p/chrome-console-tips-and-tricks.html#home Chrome的开发者工具已经强大到没朋友的地步了 ...