由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - F家 一道LIS 的变种
相关主题
微软:求一个数列中最长单调上升子列,要求O(nlogn)时间请教一个系统设计问题 (转载)
career cup book v4 9.7 题如何实现binary tree的从下到上的分层打印?
问个array in place operation的题目share 面试题
MS a0, a1, ..., b0, b1... 问题Goog面试挂了,回报一下本版
G家电面问个最长递增序列的问题
说一个我自己用的题吧Is this a DP problem?
google题这个用stack实现queue
question 2: o(1) euque and dequeue?求救: 打印binary tree
相关话题的讨论汇总
话题: int话题: vector话题: 区别话题: input话题: lis
进入JobHunting版参与讨论
1 (共1页)
h*****g
发帖数: 312
1
you are going to take some numbers as an input from a file. You need to
witer a program to find longest increasing sequence. You should process it
as soon as you are taking an input. After finishing the last input
immediately you should be able to tell the sequence. Input: 1 5 3 4 6 4
Output: 3 4 6
http://www.glassdoor.com/Interview/You-are-going-to-take-some-n
any idea?
i*********7
发帖数: 348
2
这和常见的LIS有啥不同?要求实时更新?
l*********8
发帖数: 4642
3
这个不是通常意义上的LIS吧? 这里的longest increasing sequence要求是连续的

【在 h*****g 的大作中提到】
: you are going to take some numbers as an input from a file. You need to
: witer a program to find longest increasing sequence. You should process it
: as soon as you are taking an input. After finishing the last input
: immediately you should be able to tell the sequence. Input: 1 5 3 4 6 4
: Output: 3 4 6
: http://www.glassdoor.com/Interview/You-are-going-to-take-some-n
: any idea?

h*****g
发帖数: 312
4
为啥? 连续的不是substring吗?

【在 l*********8 的大作中提到】
: 这个不是通常意义上的LIS吧? 这里的longest increasing sequence要求是连续的
l*********8
发帖数: 4642
5
Input: 1 5 3 4 6 4
Output: 3 4 6
为什么不是 1 3 4 6?
l*********8
发帖数: 4642
6
可能是题目搞错了吧

【在 l*********8 的大作中提到】
: Input: 1 5 3 4 6 4
: Output: 3 4 6
: 为什么不是 1 3 4 6?

g**********y
发帖数: 14569
7
要是不连续的lis, 一遍扫描没法出来吧。

★ 发自iPhone App: ChineseWeb - 中文网站浏览器

【在 l*********8 的大作中提到】
: Input: 1 5 3 4 6 4
: Output: 3 4 6
: 为什么不是 1 3 4 6?

f****0
发帖数: 151
8
用个queue?把数一个一个放进queue里,同时记录queue里面最长的递增序列的长度,
一旦发现有新的数列比之前的更长,就把之前的全部dequeue。这样最后一个数到了以
后,在queue头里刚开始存的递增数列就是最长数列
d*****i
发帖数: 122
9
S


【在 f****0 的大作中提到】
: 用个queue?把数一个一个放进queue里,同时记录queue里面最长的递增序列的长度,
: 一旦发现有新的数列比之前的更长,就把之前的全部dequeue。这样最后一个数到了以
: 后,在queue头里刚开始存的递增数列就是最长数列

w****x
发帖数: 2483
10
有啥区别????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????
??????????
相关主题
说一个我自己用的题吧请教一个系统设计问题 (转载)
google题如何实现binary tree的从下到上的分层打印?
question 2: o(1) euque and dequeue?share 面试题
进入JobHunting版参与讨论
G******e
发帖数: 229
11
Sorry, but why using a queue makes a difference?

【在 f****0 的大作中提到】
: 用个queue?把数一个一个放进queue里,同时记录queue里面最长的递增序列的长度,
: 一旦发现有新的数列比之前的更长,就把之前的全部dequeue。这样最后一个数到了以
: 后,在queue头里刚开始存的递增数列就是最长数列

l*********8
发帖数: 4642
12
为什么一遍扫描无法出来?
http://en.wikipedia.org/wiki/Longest_increasing_subsequence

【在 g**********y 的大作中提到】
: 要是不连续的lis, 一遍扫描没法出来吧。
:
: ★ 发自iPhone App: ChineseWeb - 中文网站浏览器

a*******8
发帖数: 110
13
应该是要即时更新吧
After finishing the last input
immediately you should be able to tell the sequence.
p*****2
发帖数: 21240
14
到底连续还是不连续?
p*****2
发帖数: 21240
15
对了,谁来讲讲LIS nlogn的算法呢?
f****0
发帖数: 151
16
感觉这篇讲得挺好的
http://hi.baidu.com/newmyl/blog/item/12f15e97ac88b06854fb965d.h

【在 p*****2 的大作中提到】
: 对了,谁来讲讲LIS nlogn的算法呢?
l*****a
发帖数: 14598
17
这个无数人会的

【在 p*****2 的大作中提到】
: 对了,谁来讲讲LIS nlogn的算法呢?
p*****2
发帖数: 21240
18

所以我得补功课

【在 l*****a 的大作中提到】
: 这个无数人会的
p*****2
发帖数: 21240
19

多谢。得好好看一下。

【在 f****0 的大作中提到】
: 感觉这篇讲得挺好的
: http://hi.baidu.com/newmyl/blog/item/12f15e97ac88b06854fb965d.h

l*****a
发帖数: 14598
20
my backup.
#include
using namespace std;
vector find_lis(vector &a)
{
vector b, p(a.size());
int u, v;
if (a.size() < 1) return b;
b.push_back(0);
for (size_t i = 1; i < a.size(); i++) {
if (a[b.back()] < a[i])
{
p[i] = b.back();
b.push_back(i);
continue;
}
for (u = 0, v = b.size()-1; u < v;) {
int c = (u + v) / 2;
if (a[b[c]] < a[i]) u=c+1; else v=c;
}
if (a[i] < a[b[u]]) {
if (u > 0) p[i] = b[u-1];
b[u] = i;
}
}
// for (u = b.size(), v = b.back(); u--; v = p[v]) b[u] = v;

u=b.size()-1;
v=b.back();
while(u) { b[u]=v; v=p[v]; u--; }
return b;
}

【在 p*****2 的大作中提到】
:
: 多谢。得好好看一下。

相关主题
Goog面试挂了,回报一下本版这个用stack实现queue
问个最长递增序列的问题求救: 打印binary tree
Is this a DP problem?请教careercup上的一道题
进入JobHunting版参与讨论
p*****2
发帖数: 21240
21

看C++a代码真费劲。n你咋还不n转java呢?

【在 l*****a 的大作中提到】
: my backup.
: #include
: using namespace std;
: vector find_lis(vector &a)
: {
: vector b, p(a.size());
: int u, v;
: if (a.size() < 1) return b;
: b.push_back(0);
: for (size_t i = 1; i < a.size(); i++) {

w****x
发帖数: 2483
22

谁考nlogn的算法可以肯定那个人是存心不要你过, 做出来也白做, 欲加之罪何患无辞

【在 l*****a 的大作中提到】
: 这个无数人会的
y**********u
发帖数: 6366
23
传说中的range minimum query啊

【在 w****x 的大作中提到】
:
: 谁考nlogn的算法可以肯定那个人是存心不要你过, 做出来也白做, 欲加之罪何患无辞

l*****a
发帖数: 14598
24
1。没什么本质区别吧?
2。这是很早以前存的,正在开始考虑转

【在 p*****2 的大作中提到】
:
: 看C++a代码真费劲。n你咋还不n转java呢?

1 (共1页)
进入JobHunting版参与讨论
相关主题
求救: 打印binary treeG家电面
请教careercup上的一道题说一个我自己用的题吧
如何用JAVA中的circular array of queue 解决Josephus problem? (转载)google题
问个题:get max value from Queue, with O(1)?question 2: o(1) euque and dequeue?
微软:求一个数列中最长单调上升子列,要求O(nlogn)时间请教一个系统设计问题 (转载)
career cup book v4 9.7 题如何实现binary tree的从下到上的分层打印?
问个array in place operation的题目share 面试题
MS a0, a1, ..., b0, b1... 问题Goog面试挂了,回报一下本版
相关话题的讨论汇总
话题: int话题: vector话题: 区别话题: input话题: lis