由买买提看人间百态

topics

全部话题 - 话题: merge
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
l****c
发帖数: 782
1
来自主题: JobHunting版 - 问leetcode上一题Merge Sorted Array
从后往前merge就不需要其他space了,困困。

array.
l***m
发帖数: 339
2
来自主题: JobHunting版 - 这种解法对吗?merge two BST
我会你这么解,肯定不会merge两个array。

root2
H****s
发帖数: 247
3
来自主题: JobHunting版 - 这种解法对吗?merge two BST
这样可以,只是不保证merge后的树balance. 而且时间是O(nlogn)
r*****e
发帖数: 146
4
来自主题: JobHunting版 - merge a1,a2,..b1,b2 to a1b1a2b2..
Given two array, array1: a1,a2,a3....,an, Array 2: b1,b2,b3...bn. How to
merge them in the form of a1,b1,a2,b2,....an,bn in O(n) time complexity and
O(1) space?
d*********g
发帖数: 154
5
来自主题: JobHunting版 - merge a1,a2,..b1,b2 to a1b1a2b2..

第2
貌似不对。假设 int[] a = {1, 3, 5, 7, 9}, int[] b = {2, 4, 6, 8, 10}. merge
好之后的结果应该是 1 2 3 4 5 6 7 8 9 10. 按照你的算法:
1. 1 | 3 5 7 9 2 4 6 8 | 10 (3和2交换,9和8交换)
2. 1 2 | 5 7 8 3 4 6 | 9 10 (5和3交换,8和6交换)
3. 1 2 3 | 7 6 5 4 | 8 9 10 (7和5交换,6和4交换)
4. 1 2 3 5 4 7 6 8 9 10 到这里结果就不对了。
Please correct me if I was wrong.
w****x
发帖数: 2483
6
来自主题: JobHunting版 - 请教各位大牛一个K-way merge 的问题

啊,不好意思,丢错版本了
struct NODE
{
int nVal;
NODE* pNext;
NODE(int n) : nVal(n), pNext(NULL) {}
};
NODE* mergeTwoList(NODE* p1, NODE* p2)
{
if (NULL == p1 && NULL == p2)
return NULL;
if (NULL == p1) return p2;
if (NULL == p2) return p1;
NODE* pIter1 = p1;
NODE* pIter2 = p2;
NODE* pIter = NULL;
NODE* pHead = NULL;
while (pIter1 != NULL && pIter2 != NULL)
{
NODE* pSmall = NULL;
if (pIter1->nVal < pIter2->nVal)
{
p... 阅读全帖
d*********g
发帖数: 154
7
来自主题: JobHunting版 - 请教各位大牛一个K-way merge 的问题

这个应该不是O(k*n)吧~~在第i个iteration里,需要merge一个长度为n的list 和一个
长度为 i*n的list,最坏情况下复杂度是(i+1)*n。于是总复杂度是 2n+3n+...+kn = O
(n*k^2)。
e******i
发帖数: 106
8
来自主题: JobHunting版 - Merge Interval那道题
merge interval 这道题一开始最好需要对各个interval进行排序么
w****g
发帖数: 3
9
来自主题: JobHunting版 - Merge Interval那道题
我用的是先sort的解法。
http://www.yangsheep.net/wuyang/wordpress/?p=727
class Solution {
public:
struct mycmpclass {
bool operator() (Interval i,Interval j) { return (i.start < j.start); }
} mycmpobject;
vector merge(vector &intervals) {
vector ans;
if(intervals.empty()) return ans;
sort(intervals.begin(), intervals.end(), mycmpobject);
Interval cur=intervals[0];
for(int i = 1; i < intervals.size(); i++) {
if(cur.end >= intervals[i].start)... 阅读全帖
e******i
发帖数: 106
10
来自主题: JobHunting版 - Merge Interval那道题
merge interval 这道题一开始最好需要对各个interval进行排序么
w****g
发帖数: 3
11
来自主题: JobHunting版 - Merge Interval那道题
我用的是先sort的解法。
http://www.yangsheep.net/wuyang/wordpress/?p=727
class Solution {
public:
struct mycmpclass {
bool operator() (Interval i,Interval j) { return (i.start < j.start); }
} mycmpobject;
vector merge(vector &intervals) {
vector ans;
if(intervals.empty()) return ans;
sort(intervals.begin(), intervals.end(), mycmpobject);
Interval cur=intervals[0];
for(int i = 1; i < intervals.size(); i++) {
if(cur.end >= intervals[i].start)... 阅读全帖
j*****y
发帖数: 1071
12
来自主题: JobHunting版 - Merge Interval那道题
二爷能讲讲你不 sort 的话是如何 merge的吗 ? thanks.

不需要吧。
b*****u
发帖数: 648
13
来自主题: JobHunting版 - leetcode 上的k way merge
今天动手做了一下才发现挺复杂
用heap做怎么由value反查到相应的list?用哈希表的话是否需要 >
因为可能有重复value? 这样代码写起来好麻烦啊。
另外两两merge的方法,和heap的时间开销一样对吧,都是(nlogk) 假设k个list,总
共n个数
c********t
发帖数: 5706
14
来自主题: JobHunting版 - leetcode 上的k way merge
原题是merge k way linkedlist啊, 做了一遍leetcode, 都忘了,
j******2
发帖数: 362
15
来自主题: JobHunting版 - interval tree vs. merge intervals
http://en.wikipedia.org/wiki/Interval_tree
读了半天interval tree的解释。有点不明白。把intervals merge起来,再用2分法就
很容易查一个点是否在里面了阿,为什么还要搞这个interval tree阿?什么情况下要
搞interval tree阿?
s**********1
发帖数: 58
16
来自主题: JobHunting版 - interval tree vs. merge intervals
Interval tree是个动态结果,可以增加删除interval,你说的merge起来的数组是不行
的。其实BST本质就是个动态的有序数组
f*********m
发帖数: 726
17
对,你说的对。我是想套用一下Merge sort递归公式T(mn)=2T(mn/2)+O(mn),然后用
Master's theorem,看样子这个题不能直接用?
a***e
发帖数: 413
18
回国一趟回来做题很难进入状态了
Merge k sorted linked lists and return it as one sorted list. Analyze and
describe its complexity.
有人面试碰到这题么?我洋洋洒洒写了很多代码,OJ说Time Limit Exceeded
class Solution {
public:
ListNode *mergeKLists(vector &lists) {
int n = lists.size();
if (n==0) return NULL;
ListNode *ret = lists[0];
for (int i=1; i {
ret = merge2Lists(ret, lists[i]);
}
return ret;
}
private:
ListNode *merge2Lists(ListNod... 阅读全帖
s********e
发帖数: 340
19
原文在这里:
http://www.programcreek.com/2013/02/leetcode-merge-k-sorted-lis
我的理解是,用PriorityQueue将需要合并的一个列表里的元素都加入到这个
PriorityQueue中。
PriorityQueue会自动对所有加入的元素进行排序。
我不明白的是下面这个部分,为什么用q.add(temp.next)再把节点再加入同一个
PriorityQueue中? 完整程序,请看上面给的链接。谢谢! 不太明白下面的部分。
while (q.size() > 0) {
ListNode temp = q.poll();

p.next = temp;

if (temp.next != null)
q.add(temp.next);
p = p.next;
}
y*****e
发帖数: 712
20
C#小哥也做这题?好巧啊。我想问你,multiple way merge和min heap这两种的
complexity是一样的吧,都是nklog(k),假设一共k lists, 每个list有n个elements

cs
i*****h
发帖数: 1534
21
用了git rebase -i commit_id
出现的所有纪录是我merge前的,我想删的那个commit没有
i*****h
发帖数: 1534
22
我的merge是 #6,用git rebase,就只能显示出#5或之前的东西,删不了我要删的
i*****h
发帖数: 1534
23
那个request里有5个commit,其中一个是错的。之前用git reset --hard HEAD~1 在
local branch里把那个错的删了,然后git push -f, master上还有。
能问下现在该怎么操作?比如我要删除merge #6的一个commit, 去master上 git
revert commit_id?

commit
i*****h
发帖数: 1534
24
组里的人都不太懂git,都是perforce过来的,组里老大规定一个人只能开一个branch
(还是永久性的),反正跟着这个流程感觉干什么都很费劲,一堆commits behind
master,然后每个人都不停解决merge conflict
g*****g
发帖数: 34805
25
A few things that can help.
1. Keep feature branches short-lived. If your ticket is created as a small
deliverable, your branch just needs to match that.
1. Squash the commits before merging to master.
2. Rebase your feature branch frequently, small, incremental conflicts are
easier to resolve than big bang.
w**z
发帖数: 8232
26
Make sure you understand
rebase vs merge
general rule is that
only rebase when you are on feature branch, never rebase when you are on
master
r*******y
发帖数: 270
27
来自主题: JobHunting版 - 问个merge interval的变体题
这个题目原型是meeting room reservation或者railroad,跟merge interval还不太一
样,你只需要求最少的满足条件的数量。
n*******n
发帖数: 446
28
来自主题: JobHunting版 - 问个merge interval的变体题
2楼说的没错,其实用不着merge interval的方法,就是把start time 于end time混一
起排序,一遍扫描,start就加一 end就减一。

发帖数: 1
29
就是给一堆interval,是在二维平面上的线段。把重合的线段都合并起来。
class Interval {
Point start;
Point end;
}
class Point {
int x; int y;
}
开始是想直接按照斜率和 start.x 排序就好了,结果发现不对,只能维持一个merge好
的序列,for循环往后,对于每个interval,找起点是不是在之前某个interval 组成的
线段上,这样时间复杂度是O(N^2),
各位大神有什么想法?
s*****p
发帖数: 30
30
每个interval 所在的直线都和 x轴有一个交点 (x, 0)(和x轴平行的也要另外考虑)
能不能对于每个interval 计算出这个x的值和, 然后按x和斜率分组。
各个组内 在 interval[(x1, y1), (x2, y2)] 退化成[x1, x2], 然后按照x 排序 再
merge?
S*********r
发帖数: 42
31
1. First group by slope, log(N)
2. Within the same slope group, check colinearity by checking whether the
line of two starts has the same slope
3. Then we can merge the colinear lines
c*******t
发帖数: 1095
32
来自主题: Living版 - 如何merge两个washer的出水管?
我有2个washer,但家里面出水口的大小只够塞进一个drainage hose,有啥办法可以
merge两个drainage hose吗?
k*********u
发帖数: 614
33
call spg
说只能一个名字的spg才能merge
w****1
发帖数: 2887
34
can't merge, but can transfer points
M***M
发帖数: 923
35
来自主题: Money版 - 求UA CO merge link (转载)
【 以下文字转载自 Travel 讨论区 】
发信人: MyIBM (Once Love), 信区: Travel
标 题: 求UA CO merge link
发信站: BBS 未名空间站 (Sat Apr 9 21:44:02 2011, 美东)
刚刚用了找到的试试
发现都不行啊
不会是死了吧
求link
谢谢
s**c
发帖数: 34339
36
来自主题: Money版 - 包子题:AA 如何merge miles
给AA打电话,要求merge
E***1
发帖数: 2534
37
来自主题: Money版 - 包子题:AA 如何merge miles
不同名字的两个账户也能merge?
l*******n
发帖数: 1328
38
来自主题: Money版 - 包子题:AA 如何merge miles
如果不同帐号不能merge的话,那那些收购miles的怎么合并呢?
P*******L
发帖数: 2637
39
merge 之后算哪个联盟?
e*****e
发帖数: 1570
40
Chase一直都可以合并2张信用卡,把credit line搞到一堆。很好。
Citi早就不行了,说是新的credit card regulation不让merge。那人家chase咋可以呢?
现在还有2张citi dividend卡。CL加在一起差不多3万了。真心想合并,Citi打死也不
让。很讨厌。破卡平时也用不上。。。
大家讨论一下?
g*******g
发帖数: 1769
41
来自主题: Money版 - mileageplus 账户merge的问题
想把父母过来时攒的mile合并到我的账户,但是好像账户名字必须一样才能merge? 改
父母账户的名字是不是很麻烦啊?请问有没有人知道如何操作啊?谢谢!
y****i
发帖数: 17878
t*****9
发帖数: 10416
43
来自主题: Money版 - aa merge accounts update ~~
login your aa account, 现在里面多出了选项 Merge accounts, 点进去输入账户就成
s***k
发帖数: 2117
44
来自主题: Money版 - aa merge accounts update ~~
一个household不同名字的帐号能merge吗?
b********m
发帖数: 429
45
来自主题: Money版 - aa merge accounts update ~~
借贴问一下,aa和us merge了以后 expiration date怎么算?
前两天收到了us寄来的信说points 快过期了
f**c
发帖数: 791
46
来自主题: shopping版 - United and Continental will merge (转载)
【 以下文字转载自 Travel 讨论区 】
发信人: ffgc (■缙云山■), 信区: Travel
标 题: United and Continental will merge
发信站: BBS 未名空间站 (Mon May 3 10:06:19 2010, 美东)
http://www.unitedcontinentalmerger.com/
use continental's logo but will be named United Airline, interesting...
H*V
发帖数: 2770
47
citi两个card花够了1500也都拿到了75000mile,要aa合并两个AAdvantage account
结果只剩一个75000。
Here are some things to note about the merging of your accounts:
* Any duplicate mileage credit will not be transferred. This means, for
example, if the same flight on the same day was credited in both
accounts, it will only appear one time in the account you retain.
是不是CSR搞错了,能argue回来吗
搞笑的是email末尾附了一段:
P.S. Did you know you can add a Citi Select® / AAdvantage® American
Express® card to your wallet and earn 10,000... 阅读全帖
a******w
发帖数: 774
48
你应该是被发现申请了两张卡。。
应该先用掉再merge
现在只能argure试试看了
祝好运
e********u
发帖数: 587
49
明显要不回来啊,这种bonus都是对同一个人首次有效.lz太可爱了,没事merge什么.
H*V
发帖数: 2770
50
only same name and address can merge
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)