Redian新闻
>
求:喷果树红蜘蛛的药名
avatar
求:喷果树红蜘蛛的药名# gardening - 拈花惹草
b*e
1
Given a NxN matrix with 0s and 1s. Now whenever you encounter a 0 make the
corresponding row and column elements 0.
Flip 1 to 0 and 0 remains as they are.
for example
1 0 1 1 0
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
results in
0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 0 0 0
0 0 1 1 0
my solution is define a function remove1(x1,y1,x2,y2)
(x1,y1) is the matrix start point, and (x2,y2) is the end point
if(i,j) == 1, we need remove all 1 from i row and j column
so we divide into four small matrix
resrucive
avatar
p*e
2
是桔子树的叶子,几天没看,结果叶子上都是叫红蜘蛛(老家都是这样叫)就是很小很
小的虫子。颜色一点点红,肉眼看不出蜘蛛的样子。
印象当中不是用的普通的杀虫害的药
avatar
t*a
3
I don't think you are right.
when you dive in some small matrix, find a 0, and start removing 1, you
might miss the 1 in another small matrix
avatar
T*m
4
瓶子上画有红蜘蛛的肯定能杀红蜘蛛。

很小的虫子。颜色一点点红,肉眼看不出蜘蛛的样子。

【在 p********e 的大作中提到】
: 是桔子树的叶子,几天没看,结果叶子上都是叫红蜘蛛(老家都是这样叫)就是很小很
: 小的虫子。颜色一点点红,肉眼看不出蜘蛛的样子。
: 印象当中不是用的普通的杀虫害的药

avatar
b*e
5
you are the man:)
do you have any solution?

【在 t****a 的大作中提到】
: I don't think you are right.
: when you dive in some small matrix, find a 0, and start removing 1, you
: might miss the 1 in another small matrix

avatar
p*e
6
美国这边对应的是什么?
石硫合剂或机油乳剂100倍加有机磷农药
网上搜到
如何防治果树红蜘蛛,用什么杀虫药效果最佳?
早治:
防治红蜘蛛要在采果后15天立即用高浓度石硫合剂或机油乳剂100倍加有机磷农药进行
清园。春季在春芽萌发至开花前的化学防治,是控制红蜘蛛危害的关键时机。一年中,
只要在春秋两季,当害螨初发时用两种药剂各喷一次,就基本上可控制全年红蜘蛛的危
害,并对次年害螨的发生也有明显的抑制作用。巧治:红蜘蛛发生高峰为春季4-6月,
秋季9-11月。防治红蜘蛛要抓住早春3-4月。红蜘蛛成、若螨平均每叶2头,或50%叶片
有虫时治。

【在 T*******m 的大作中提到】
: 瓶子上画有红蜘蛛的肯定能杀红蜘蛛。
:
: 很小的虫子。颜色一点点红,肉眼看不出蜘蛛的样子。

avatar
s*a
7
How about use 2 arrays row[] and col[](all initialized 1) to record whether
each row and column should contain 1? Just scan the matrix to and set row[i
] = 0 and col[j] = 0 when matrix[i][j] = 0. Then set each matrix[i][j] = row
[i]*col[j].
Complexity is O(n^2).

【在 b********e 的大作中提到】
: you are the man:)
: do you have any solution?

avatar
l*c
8
this is a MSFT onsite question(I was asked), no extra space allowed
I don't know which tech company first asked this question, seems they copy the questions each other.

【在 b********e 的大作中提到】
: Given a NxN matrix with 0s and 1s. Now whenever you encounter a 0 make the
: corresponding row and column elements 0.
: Flip 1 to 0 and 0 remains as they are.
: for example
: 1 0 1 1 0
: 0 1 1 1 0
: 1 1 1 1 1
: 1 0 1 1 1
: 1 1 1 1 1
: results in

avatar
t*j
9
把matrix第一行和第一栏作为临时存储空间
对于每一row, 加到第一row(或者&&也行)。该函数变成
4 3 5 5 3
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
同理 对于第一列,则函数变成
20 3 5 5 3
3 1 1 1 0
5 1 1 1 1
4 0 1 1 1
5 1 1 1 1
扫描第一行及第一列(除A1,1以外),若不足n,则改行全部改0,否则改1.
20 0 1 1 0
3 0 1 1 0
5 0 1 1 0
4 0 1 1 0
5 0 1 1 0
把matrix第一行和第一栏作为临时存储空间
对于每一row, 加到第一row(或者&&也行)。该函数变成
4 3 5 5 3
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
同理 对于第一列,则函数变成
20 3 5 5 3
3 1 1 1 0
5 1 1 1 1
4 0 1 1 1
5 1 1 1 1
扫描第一行及第一列(除A1,1以外),若不足n,则该行全部改0,否则改此累计数字改
为1。
20 0 1 1 0
0 0 0 0 0
1 0

【在 b********e 的大作中提到】
: Given a NxN matrix with 0s and 1s. Now whenever you encounter a 0 make the
: corresponding row and column elements 0.
: Flip 1 to 0 and 0 remains as they are.
: for example
: 1 0 1 1 0
: 0 1 1 1 0
: 1 1 1 1 1
: 1 0 1 1 1
: 1 1 1 1 1
: results in

avatar
h*k
10
对于A1,1 若第一行或者第一列其他数字有0,则第一行第一列全改为0.
你怎么做到这个的?既然你已经用第一行和第一列存了临时的和,原来的数据已经不在
了啊

【在 t*****j 的大作中提到】
: 把matrix第一行和第一栏作为临时存储空间
: 对于每一row, 加到第一row(或者&&也行)。该函数变成
: 4 3 5 5 3
: 0 1 1 1 0
: 1 1 1 1 1
: 1 0 1 1 1
: 1 1 1 1 1
: 同理 对于第一列,则函数变成
: 20 3 5 5 3
: 3 1 1 1 0

avatar
t*j
11
扫描第一行及第一列(除A1,1以外),若不足n,则该行全部改0,否则改此累计数字改
为1。
这句话是把非A11的累计数字位都改了。

【在 h**k 的大作中提到】
: 对于A1,1 若第一行或者第一列其他数字有0,则第一行第一列全改为0.
: 你怎么做到这个的?既然你已经用第一行和第一列存了临时的和,原来的数据已经不在
: 了啊

avatar
b*n
12
CareerCup上的原题?
avatar
l*c
13
CareerCup 没有给出正确答案

【在 b*****n 的大作中提到】
: CareerCup上的原题?
avatar
a*k
14
I would use bit AND (&) operation (cumulatively).
time: O(n^2), space O(1).
avatar
b*y
15
1,按行扫描,如果遇到0,将该行所有1改成2,换到下一行
2,按列扫描,如果遇到0,将该列所有1改成2,换到下一列
3,扫描整个矩阵a[i][j]/=2;
time:O(mn), space 0
avatar
t*j
16
and 和 累加 其实一样,都行。

【在 a**********k 的大作中提到】
: I would use bit AND (&) operation (cumulatively).
: time: O(n^2), space O(1).

avatar
s*e
17
this is not space 0
because, if each element in the matrix is stored in a bit. how would this
work?

【在 b******y 的大作中提到】
: 1,按行扫描,如果遇到0,将该行所有1改成2,换到下一行
: 2,按列扫描,如果遇到0,将该列所有1改成2,换到下一列
: 3,扫描整个矩阵a[i][j]/=2;
: time:O(mn), space 0

avatar
s*e
18
you are assuming the element in the matrix is an integer instead of a
boolean, which is a strong assumption

【在 t*****j 的大作中提到】
: 把matrix第一行和第一栏作为临时存储空间
: 对于每一row, 加到第一row(或者&&也行)。该函数变成
: 4 3 5 5 3
: 0 1 1 1 0
: 1 1 1 1 1
: 1 0 1 1 1
: 1 1 1 1 1
: 同理 对于第一列,则函数变成
: 20 3 5 5 3
: 3 1 1 1 0

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。