Data Structure Array: Longest Monotonically Increasing Subsequence Size
http://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <fstream>
#include <map>
using namespace std; int maxsum(int arr[], int n) {
vector<int> tail;
tail.push_back(arr[]);
for (int i = ; i < n; i++) {
if (arr[i] < tail[]) tail[] = arr[];
else if (arr[i] > tail[tail.size()-]) tail.push_back(arr[i]);
else {
int mid;
int left = ;
int right = tail.size() - ;
while (left < right) {
mid = (left + right) / ;
if (tail[mid] < arr[i]) left = mid + ;
else right = mid - ;
}
mid = (left + right) / ;
tail[mid] = arr[i];
cout << "tail[" << mid << "] is arr[" << i << "] = " << arr[i] << endl;
}
}
return tail.size();
} int main() {
int arr[] = {, , , , , , , , };
cout << maxsum(arr, ) << endl;
return ;
}
Data Structure Array: Longest Monotonically Increasing Subsequence Size的更多相关文章
- [LeetCode] Longest Continuous Increasing Subsequence 最长连续递增序列
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- LeetCode 674. Longest Continuous Increasing Subsequence最长连续递增序列 (C++/Java)
题目: Given an unsorted array of integers, find the length of longest continuous increasing subsequenc ...
- [LeetCode] 674. Longest Continuous Increasing Subsequence 最长连续递增序列
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- LeetCode 674. Longest Continuous Increasing Subsequence (最长连续递增序列)
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- [Swift]LeetCode674. 最长连续递增序列 | Longest Continuous Increasing Subsequence
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...
- [Leetcode]674. Longest Continuous Increasing Subsequence
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- [LeetCode&Python] Problem 674. Longest Continuous Increasing Subsequence
Given an unsorted array of integers, find the length of longest continuousincreasing subsequence (su ...
- leetcode300. Longest Increasing Subsequence 最长递增子序列 、674. Longest Continuous Increasing Subsequence
Longest Increasing Subsequence 最长递增子序列 子序列不是数组中连续的数. dp表达的意思是以i结尾的最长子序列,而不是前i个数字的最长子序列. 初始化是dp所有的都为1 ...
- 674. Longest Continuous Increasing Subsequence最长连续递增子数组
[抄题]: Given an unsorted array of integers, find the length of longest continuous increasing subseque ...
随机推荐
- JavaScript 匹配浮点数
//匹配整数,正小数 appUtils.bindEvent($(_pageId+" .remind-list-con input"),function(){ var reg = / ...
- @Autowired @Transaction @Service同时出现。
对于@Autowired,如果只写这些,肯定是根据类型自动装配这个没问题. @Service public class AcRoleServiceImpl implements AcRoleServi ...
- 【翻译自mos文章】asm 归档路径满了
asm 归档路径满了 參考原文: ASM Archive destination is full. (Doc ID 351547.1) 适用于: Oracle Server - Enterprise ...
- 运行./cpp.sh,显示command not found
首先运行ls -l 查看这个文件的属性是否可执行drwxrwxrwx对当前用户必须具有可执行权限(即含有x符号)如果没有可以运行chmod 777 cpp.sh 添加可执行权限
- eureka集群高可用配置,亲测成功配置(转)
转自大神的文章:https://blog.csdn.net/tianyaleixiaowu/article/details/78184793 网上讲这个东西的很多,抄来抄去的,大部分类似,多数没讲明白 ...
- MySQL四-2:完整性约束
阅读目录 一 介绍 二 not null与default 三 unique 四 primary key 五 auto_increment 六 foreign key 七 作业 一 介绍 约束条件与数据 ...
- 【Caffe代码解析】Blob
主要功能: Blob 是Caffe作为传输数据的媒介,不管是网络权重參数,还是输入数据,都是转化为Blob数据结构来存储,网络,求解器等都是直接与此结构打交道的. 其直观的能够把它看成一个有4纬的结构 ...
- linux sublime python
(三)配置python3编译环境 1.点击上部菜单栏Tools->Build System ->new Build System 2.点击之后,会出现一个空的配置文件,此时,往这个空配置文 ...
- python实现测试中常用的脚本(待完善)
一. Python操作MySQL数据库,简单的增删改查 # coding=utf-8 ''' Created on 2015年5月12日 @author: Administrator ''' impo ...
- struts2 拦截器,使用spring注入
ActionContext actionContext = invocation.getInvocationContext();ServletContext context = (ServletCon ...