由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 谁给个不是brute force的解法
相关主题
一道Google题问个算法题2
求解一道面试题Ask a amazon question from careercup.
01 Knapsack brute force code求Bless附送面经
一道coding test题问一道google面试题(from careercup)
请教个面试题问道题 正方体八顶点
请教背包问题。问一道G家经典老题
面试题bb家电面
请教一个DP的问题DP解法的题目是不是肯定是多项式的?
相关话题的讨论汇总
话题: signs话题: brute话题: solution话题: force话题: assume
进入JobHunting版参与讨论
1 (共1页)
z**********g
发帖数: 209
1
You're given N signed integers a[1..N].
You need to find N correct signs s[1..N] (that is, numbers s[i] = +/-1),
such that
a[1]*s[1] + a[2]*s[2] + .. + a[N]*s[N] = 0.
Assume that the solution always exists.
Example: a = {5, 7, 3, -8, 1};
then the signs are: s = {1, 1, -1, 1, -1}
because: 5 + 7 - 3 - 8 - 1 = 0
(or symmetric solution: s = {-1, -1, 1, -1, 1})
brute force 2^n.
a***9
发帖数: 364
2
这个是NP hard吧,reduce subset sum to this one

【在 z**********g 的大作中提到】
: You're given N signed integers a[1..N].
: You need to find N correct signs s[1..N] (that is, numbers s[i] = +/-1),
: such that
: a[1]*s[1] + a[2]*s[2] + .. + a[N]*s[N] = 0.
: Assume that the solution always exists.
: Example: a = {5, 7, 3, -8, 1};
: then the signs are: s = {1, 1, -1, 1, -1}
: because: 5 + 7 - 3 - 8 - 1 = 0
: (or symmetric solution: s = {-1, -1, 1, -1, 1})
: brute force 2^n.

m*****g
发帖数: 226
3
knapsack?
1 (共1页)
进入JobHunting版参与讨论
相关主题
DP解法的题目是不是肯定是多项式的?请教个面试题
你们leetcode都刷到啥程度才敢去面FLG请教背包问题。
Substring with Concatenation of All Words 还有更简洁的解法吗?面试题
这一题有没有什么比brute force更好的解法?请教一个DP的问题
一道Google题问个算法题2
求解一道面试题Ask a amazon question from careercup.
01 Knapsack brute force code求Bless附送面经
一道coding test题问一道google面试题(from careercup)
相关话题的讨论汇总
话题: signs话题: brute话题: solution话题: force话题: assume