由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 这道题怎么做的?
相关主题
这道题,怎么做呀?问个array in place operation的题目
不用暴力,这道题有没有优化解c++ class default functions?
这道题是选A 吗?大家帮我看看我的recruiter是在帮我还是在玩我?
这道题有没有答案呀?几道a家onsite问题讨论贴
C++ 一小题Divide a number by 3 without using *, /, +, -, % operators [转载]
a question about bits operation弱问一下,cracking the coding interview上有关bit manipulation的解释正确么
c++ 问题Amazon China Operation Manager Position
Bloomberg phone interview (intern)Polish Notation
相关话题的讨论汇总
话题: array话题: prv话题: operations话题: int话题: vec
进入JobHunting版参与讨论
1 (共1页)
f********a
发帖数: 165
1
Give an array, operations on array are add(l,r,v), n operators, how to do
the operations in O(n)?
g***j
发帖数: 1275
2
什么意思?
举个例子?

【在 f********a 的大作中提到】
: Give an array, operations on array are add(l,r,v), n operators, how to do
: the operations in O(n)?

f********a
发帖数: 165
3
array 1 2 3 4 5
operation 0 1 2 ->it becomes 3 4 3 4 5
operation 2 3 2 -> it becomes 3 4 5 6 5 ...

【在 g***j 的大作中提到】
: 什么意思?
: 举个例子?

g***j
发帖数: 1275
4
老大,我很愚笨,还是没有看明白什么意思。就不能说详细一点么?当然,你不想说我
也不介意。

【在 f********a 的大作中提到】
: array 1 2 3 4 5
: operation 0 1 2 ->it becomes 3 4 3 4 5
: operation 2 3 2 -> it becomes 3 4 5 6 5 ...

c*****0
发帖数: 19
5
对区间[l,r]内的值都增加v,楼主为啥只要O(n)的时间复杂度

【在 g***j 的大作中提到】
: 老大,我很愚笨,还是没有看明白什么意思。就不能说详细一点么?当然,你不想说我
: 也不介意。

p*****2
发帖数: 21240
6
(defn f [l r v vec] (concat (take l vec) (map #(+ % v) (subvec vec l (inc r)
)) (nthrest vec (inc r))))
f*******4
发帖数: 64
7
struct Interval { int l, r, v; };
void solve(vector &a, const vector &adds) {
vectorb(a.size()+1, 0);
for (auto e:adds)
b[e.l] += e.v, b[e.r+1] -= e.v;

for (int i=0, prv=0; i prv += b[i];
a[i] += prv;
}
}

【在 f********a 的大作中提到】
: Give an array, operations on array are add(l,r,v), n operators, how to do
: the operations in O(n)?

m*******m
发帖数: 80
8
真是大爷啊, 上来问题都舍不得多打几个字把题目说清楚点...
a******e
发帖数: 710
9
二爷威武,我还没看懂题目,您连解答都写出来了。 Orz

r)

【在 p*****2 的大作中提到】
: (defn f [l r v vec] (concat (take l vec) (map #(+ % v) (subvec vec l (inc r)
: )) (nthrest vec (inc r))))

1 (共1页)
进入JobHunting版参与讨论
相关主题
Polish NotationC++ 一小题
我公司在招 DevOps Sr. Operations Software Engineera question about bits operation
Amazon team match的问题c++ 问题
smiley同学的面试题分类总结链接谁那有Bloomberg phone interview (intern)
这道题,怎么做呀?问个array in place operation的题目
不用暴力,这道题有没有优化解c++ class default functions?
这道题是选A 吗?大家帮我看看我的recruiter是在帮我还是在玩我?
这道题有没有答案呀?几道a家onsite问题讨论贴
相关话题的讨论汇总
话题: array话题: prv话题: operations话题: int话题: vec