Redian新闻
>
“没看见,没看见。”后清隐身技术早已普及
avatar
“没看见,没看见。”后清隐身技术早已普及# Joke - 肚皮舞运动
x*o
1
[Coding Q1]: Given an array A, output another array B such that B[k]=product
of all elements in A but A[k]. You are not allowed to use division.
avatar
h*a
2
agent 说final walk 发现问题可以退出. 可是已经过了contignecy. 怎么退出呢?
deposit怎么办?
另外, 买房时什么时候请律师? 我都是跟agent联系? 没涉及到律师. 需要自己请律师
吗?
avatar
n*o
3
柯小明要求习近平出国聚会
习近平在河北省也待了三年,这三年与在耿飙叔叔身边的三年有天壤之别,既是他
仕途的重要转折点,也是人生遭遇挫折的磨难时期。正因为父母为其把舵,他做出的选
择使他25年之后能够一步登天。
到了正定县,遭遇的第一个困境,是妻子柯小明当时已经在英国,准备在国外发展
,不打算回来了,要求习近平也尽快出国聚会,否则离婚。柯小明是中国当时驻英大使
柯华的女儿,其母张明也是陕西人。习近平当时还不到30岁,正在奋力提升为县委书记
,要“土仕途”,还是去“洋插队”?想来如此人生决断,不是他个人能做出的,大主
意当然是英明的母亲齐心拿出,最后是“孔雀东南飞”。
据说,习近平到厦门担任副市长,当时在高干子弟中十分耀眼,前岳父母柯华、张
明就后悔了,感到女儿选择离婚是选错了。柯小明经过商,在香港有房产,已经多年不
工作,长期在北京父母家居住。
柯华夫妇如今都九十多岁了,身体很好。近年有传,柯前大使到青岛疗养,在专职
护士们的照顾下,下水游泳,因为年纪大了,入水和进浴池一样,一丝不挂。出水之后
,自己才发现不妥,径直走到护士小姐们跟前问:“看见了吗?”护士们连声说:“没
看见,没看见。”他才踏实地去穿衣服了。 (《明镜月刊》第8期)
avatar
i*e
4
这题这里有解答,你可以看看:
http://www.ihas1337code.com/2010/04/multiplication-of-numbers.h
给你另一题的变种:
Equilibrium index of an array is an index such that the sum of elements at
lower indexes is equal to the sum of elements at higher indexes. For example
, in an array A:
A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0
3 is an equilibrium index, because:
A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
6 is also an equilibrium index, because sum of zero elements is zero, i.e.,
A[0] + A[1] + A[2] + A[3] + A[4] + A[5]=0
7 is not an equilibrium index, because it is not a valid index of array A.
Write a function int equilibrium(int[] arr, int n); that given a sequence
arr[] of size n, returns an equilibrium index (if any) or -1 if no
equilibrium indexes exist.
一些常见面试题的答案与总结 -
http://www.ihas1337code.com
avatar
a*i
5
必须在contract里面写明final walk可以退出,要不然就不能退出,绝对不能听agent
的,所有的agent都不希望你能退出,你退出他的钱找谁要去?律师必须自己去请一个。

【在 h****a 的大作中提到】
: agent 说final walk 发现问题可以退出. 可是已经过了contignecy. 怎么退出呢?
: deposit怎么办?
: 另外, 买房时什么时候请律师? 我都是跟agent联系? 没涉及到律师. 需要自己请律师
: 吗?

avatar
s*x
6
你的网站还不错, 怎么起了这么个怪怪的名字?

example
,

【在 i**********e 的大作中提到】
: 这题这里有解答,你可以看看:
: http://www.ihas1337code.com/2010/04/multiplication-of-numbers.h
: 给你另一题的变种:
: Equilibrium index of an array is an index such that the sum of elements at
: lower indexes is equal to the sum of elements at higher indexes. For example
: , in an array A:
: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0
: 3 is an equilibrium index, because:
: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
: 6 is also an equilibrium index, because sum of zero elements is zero, i.e.,

avatar
j*y
7
合同为准,标准的合同没法在final walk时退出了
avatar
O*n
8
size = 10
a = []
for i in range(size):
a.append(i+1)
print a

t1 = [0]*size
t2 = [0]*size
result = 1
for i in range(size):
result = result * a[i]
t[i] = result
result = 1
for i in range(size-1, -1, -1):
result = result * a[i]
t2[i] = result

output = [0]*size
for i in range(1, size-1):
output[i] = t1[i-1]*t2[i+1]
output[0] = t2[1]
output[size-1] = t1[size-2]
print output

product

【在 x********o 的大作中提到】
: [Coding Q1]: Given an array A, output another array B such that B[k]=product
: of all elements in A but A[k]. You are not allowed to use division.

avatar
h*a
9
如果final walk时发生意外事故, 如水管爆裂, 火灾, 冰雹, ...房子损坏, 怎么办?
大家买房时, 都自己请律师吗? 什么时候请? 签agreement 时吗?
xiexie

agent
个。

【在 a****i 的大作中提到】
: 必须在contract里面写明final walk可以退出,要不然就不能退出,绝对不能听agent
: 的,所有的agent都不希望你能退出,你退出他的钱找谁要去?律师必须自己去请一个。

avatar
y*n
10
变题有类似不能用减法的要求吗?

at
example
i.e.,

【在 i**********e 的大作中提到】
: 这题这里有解答,你可以看看:
: http://www.ihas1337code.com/2010/04/multiplication-of-numbers.h
: 给你另一题的变种:
: Equilibrium index of an array is an index such that the sum of elements at
: lower indexes is equal to the sum of elements at higher indexes. For example
: , in an array A:
: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0
: 3 is an equilibrium index, because:
: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
: 6 is also an equilibrium index, because sum of zero elements is zero, i.e.,

avatar
a*i
11
一般Contract里面要说明从contract到closing其间的保险费用谁支付,无论谁支付,
如果你没有写final walk可以退出,你这说的这些情况只能找保险公司.不过虽然你很
想写,但是99%的seller不会同意写,所以最大可能是你去找保险公司,或者放弃定
金。
签contract的时候要自己请律师,不要去找agent推荐的律师,contract不同于offer,
binding能力很强的,不是很容易walk away的,

【在 h****a 的大作中提到】
: 如果final walk时发生意外事故, 如水管爆裂, 火灾, 冰雹, ...房子损坏, 怎么办?
: 大家买房时, 都自己请律师吗? 什么时候请? 签agreement 时吗?
: xiexie
:
: agent
: 个。

avatar
W*r
12
K, 应该再要求不能用乘法 ~~
avatar
m*n
13
对,一定要在这期间买保险,而且最好在contract 明确的注明,如果有类似的情况,
seller bear loss,因为大部分州如果没明确的说,default是认为buyer bear loss
的。因为在签了binding的purchase agreement之后, 基于equitable conversion,
buyer被认为是equitable 的owner,所以要负责在closing之前的loss.

【在 a****i 的大作中提到】
: 一般Contract里面要说明从contract到closing其间的保险费用谁支付,无论谁支付,
: 如果你没有写final walk可以退出,你这说的这些情况只能找保险公司.不过虽然你很
: 想写,但是99%的seller不会同意写,所以最大可能是你去找保险公司,或者放弃定
: 金。
: 签contract的时候要自己请律师,不要去找agent推荐的律师,contract不同于offer,
: binding能力很强的,不是很容易walk away的,

avatar
i*e
14
sdlx:
我也觉得怪怪,似乎不是很多人懂 1337 的意思。你有想到其他的名字吗?
Oceanian:
你这个可以,但是用了 2*n 的空间。
yulian:
可以减。只要不用额外空间就行,O(n) run time。
一些常见面试题的答案与总结 -
http://www.ihas1337code.com
avatar
z*d
15
看了下ihas1337code上的解法,
思路类似,觉得对equilibram的话改下就好
for (int i = 0; i < n; i++) {
OUTPUT[i] += left;
OUTPUT[n - 1 - i] -= right;
left += A[i];
right -= A[n - 1 - i];
}
然后看output里值为0的就是要找的index
可能会找到不止一个
这样算不算用额外空间。。
avatar
r*y
16
good idea, but last line should be right+= A[n - 1 - i];

【在 z****d 的大作中提到】
: 看了下ihas1337code上的解法,
: 思路类似,觉得对equilibram的话改下就好
: for (int i = 0; i < n; i++) {
: OUTPUT[i] += left;
: OUTPUT[n - 1 - i] -= right;
: left += A[i];
: right -= A[n - 1 - i];
: }
: 然后看output里值为0的就是要找的index
: 可能会找到不止一个

avatar
N*r
17
能不能这样考虑呢:先获取所有元素的乘积,然后除以当前的元素就可以得到product
of all elements but A[k].
int product = 1;
for(int i = 0; i < A.length; i++)
{
product *= A[i];
}
for(int j = 0; j < A.length; j++)
{
B[j] = product/a[j];
}
不知道可不可行,请指教。。
avatar
m*t
18

product
题目已经说了不能用除法。

【在 N******r 的大作中提到】
: 能不能这样考虑呢:先获取所有元素的乘积,然后除以当前的元素就可以得到product
: of all elements but A[k].
: int product = 1;
: for(int i = 0; i < A.length; i++)
: {
: product *= A[i];
: }
: for(int j = 0; j < A.length; j++)
: {
: B[j] = product/a[j];

avatar
N*r
19
没看到不许用除法 :)
avatar
m*t
20

You are not allowed to use division.

【在 N******r 的大作中提到】
: 没看到不许用除法 :)
avatar
N*r
21
谢谢提醒。我的意思是做题之前没留意到不许用除法

【在 m****t 的大作中提到】
:
: You are not allowed to use division.

avatar
f*4
22
你要是把网站改成中文的那就更好,特别是题目和讨论
别让老印啥的看了和我们竞争

【在 i**********e 的大作中提到】
: sdlx:
: 我也觉得怪怪,似乎不是很多人懂 1337 的意思。你有想到其他的名字吗?
: Oceanian:
: 你这个可以,但是用了 2*n 的空间。
: yulian:
: 可以减。只要不用额外空间就行,O(n) run time。
: 一些常见面试题的答案与总结 -
: http://www.ihas1337code.com

avatar
z*d
23

哦,对的,疏忽下打错了。。
谢谢指出~~

【在 r*******y 的大作中提到】
: good idea, but last line should be right+= A[n - 1 - i];
avatar
i*e
24
这样算额外空间,因为你需要另一个数组。
这题不用想太复杂,数组遍历两次就行,不需要额外空间。
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

【在 z****d 的大作中提到】
: 看了下ihas1337code上的解法,
: 思路类似,觉得对equilibram的话改下就好
: for (int i = 0; i < n; i++) {
: OUTPUT[i] += left;
: OUTPUT[n - 1 - i] -= right;
: left += A[i];
: right -= A[n - 1 - i];
: }
: 然后看output里值为0的就是要找的index
: 可能会找到不止一个

avatar
g*k
25
C[i]=A[0]*A[1]*...*A[i]
D[j]=A[j]*A[j+1]*...A[N]
B[k]=C[k-1]*D[k+1]

product

【在 x********o 的大作中提到】
: [Coding Q1]: Given an array A, output another array B such that B[k]=product
: of all elements in A but A[k]. You are not allowed to use division.

avatar
g*k
26
如果可以用减法,那么就是先求总和sum, let left = 0, right = sum
然后从头遍历, 对于index 0, left = 0, right = right - A[0]
对于index i,
left += A[i-1]
right -= A[i]
如果left == right 则返回。

example
,

【在 i**********e 的大作中提到】
: 这题这里有解答,你可以看看:
: http://www.ihas1337code.com/2010/04/multiplication-of-numbers.h
: 给你另一题的变种:
: Equilibrium index of an array is an index such that the sum of elements at
: lower indexes is equal to the sum of elements at higher indexes. For example
: , in an array A:
: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0
: 3 is an equilibrium index, because:
: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
: 6 is also an equilibrium index, because sum of zero elements is zero, i.e.,

avatar
g*k
27
I checked your solution. Brilliant!!!
巧妙

example
,

【在 i**********e 的大作中提到】
: 这题这里有解答,你可以看看:
: http://www.ihas1337code.com/2010/04/multiplication-of-numbers.h
: 给你另一题的变种:
: Equilibrium index of an array is an index such that the sum of elements at
: lower indexes is equal to the sum of elements at higher indexes. For example
: , in an array A:
: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0
: 3 is an equilibrium index, because:
: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
: 6 is also an equilibrium index, because sum of zero elements is zero, i.e.,

avatar
g*i
28
先遍历一遍求总的sum
然后用一个变量存储0到i-1的sum,看看是不是等于(sum-a[i])/2.0.

example
,

【在 i**********e 的大作中提到】
: 这题这里有解答,你可以看看:
: http://www.ihas1337code.com/2010/04/multiplication-of-numbers.h
: 给你另一题的变种:
: Equilibrium index of an array is an index such that the sum of elements at
: lower indexes is equal to the sum of elements at higher indexes. For example
: , in an array A:
: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0
: 3 is an equilibrium index, because:
: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
: 6 is also an equilibrium index, because sum of zero elements is zero, i.e.,

avatar
c*t
29
怎么数组遍历两次解决equilibrium index的问题?in O(n).
谢谢!

【在 i**********e 的大作中提到】
: 这样算额外空间,因为你需要另一个数组。
: 这题不用想太复杂,数组遍历两次就行,不需要额外空间。
: 一些常见面试题的答案与总结 -
: http://www.ihas1337code.com

avatar
i*e
30
请参考 #19 的答案。
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

【在 c*********t 的大作中提到】
: 怎么数组遍历两次解决equilibrium index的问题?in O(n).
: 谢谢!

avatar
s*g
31
不懂它为啥不叫做i have 1337而用has

【在 i**********e 的大作中提到】
: sdlx:
: 我也觉得怪怪,似乎不是很多人懂 1337 的意思。你有想到其他的名字吗?
: Oceanian:
: 你这个可以,但是用了 2*n 的空间。
: yulian:
: 可以减。只要不用额外空间就行,O(n) run time。
: 一些常见面试题的答案与总结 -
: http://www.ihas1337code.com

avatar
b*r
32
what if sum overflow?

【在 i**********e 的大作中提到】
: 请参考 #19 的答案。
: 一些常见面试题的答案与总结 -
: http://www.ihas1337code.com

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