y*n
2 楼
是现场写code的面试。
第一道是写一个函数,两个参数(String prefix, String s), 返回true如果s有
prefix
第二道是写一个函数,两个参数(int[] a, int sum), 找出数组里加起来是sum的几个数
我第一题算是答出来了,第二题没做完,没有好的思路。。。
大人指教一下
第一道是写一个函数,两个参数(String prefix, String s), 返回true如果s有
prefix
第二道是写一个函数,两个参数(int[] a, int sum), 找出数组里加起来是sum的几个数
我第一题算是答出来了,第二题没做完,没有好的思路。。。
大人指教一下
v*9
3 楼
电影完整版,带字幕的,很难找啊!
h*e
4 楼
把iphone4里边的sim卡拿出来,用剪刀将卡从正中间剪成两半,然后将左边那半放回
去打一次电话,以后想换什么卡都ok!简单吧。
去打一次电话,以后想换什么卡都ok!简单吧。
b*i
5 楼
今年Oracle JDK8.0 Arm到底有什么功能?能直接控制串口吗?
b*d
6 楼
恭喜!美联社?
l*z
8 楼
有字幕和没字幕没啥区别。。。我看的台湾版带字幕的,字幕错的已经到了干扰看片的
程度了。。。
程度了。。。
l*e
13 楼
s*a
14 楼
我试了,成功了!
b*i
20 楼
刚搞出来就死了?
我说的是Java SE Embedded 8
http://docs.oracle.com/javame/8.0/api/dio/api/index.html
【在 d****i 的大作中提到】
: Don't use java on embedded. It is dead. No company uses it. Even Oracle
: itself cannot convince itself to use it in embedded project.
C*S
21 楼
不得瑟会怀孕吗?
a*g
24 楼
lz牛比,这你都知道
d*i
25 楼
I've attended ESC and talked to Oracle representative about this, that's
what they told me. We are an Oracle shop. Even we don't use it for embedded
project.
【在 b***i 的大作中提到】
:
: 刚搞出来就死了?
: 我说的是Java SE Embedded 8
: http://docs.oracle.com/javame/8.0/api/dio/api/index.html
what they told me. We are an Oracle shop. Even we don't use it for embedded
project.
【在 b***i 的大作中提到】
:
: 刚搞出来就死了?
: 我说的是Java SE Embedded 8
: http://docs.oracle.com/javame/8.0/api/dio/api/index.html
b*a
26 楼
某人惊出一身冷汗。
【在 s**********e 的大作中提到】
: 是这个吗?
: http://news.creaders.net/photo/newsViewer.php?nid=518762&id=115
【在 s**********e 的大作中提到】
: 是这个吗?
: http://news.creaders.net/photo/newsViewer.php?nid=518762&id=115
p*9
27 楼
bool calculateSum(int[] A, int s, int sum)
{
if( sum < 0 || s < 0 ) return false;
if( A[s] == sum )
{
printf(" %d ", A[s]);
return true;
}
if( calculateSum(A, s-1, sum) ) return true;
if( calculateSum(A, s-1, sum-A[s] )
{
printf(" %d ", A[s]);
return true;
}
return false;
}
【在 y****n 的大作中提到】
: 谢谢!能讲得更具体点吗?
: 我当时是要我把code写出来啊
{
if( sum < 0 || s < 0 ) return false;
if( A[s] == sum )
{
printf(" %d ", A[s]);
return true;
}
if( calculateSum(A, s-1, sum) ) return true;
if( calculateSum(A, s-1, sum-A[s] )
{
printf(" %d ", A[s]);
return true;
}
return false;
}
【在 y****n 的大作中提到】
: 谢谢!能讲得更具体点吗?
: 我当时是要我把code写出来啊
e*3
28 楼
thanks!
【在 l*****e 的大作中提到】
: 未删节版,但是不带字幕
: http://www.shuangtv.net/dy/nxnwmyqzdnh-19056-1.html
【在 l*****e 的大作中提到】
: 未删节版,但是不带字幕
: http://www.shuangtv.net/dy/nxnwmyqzdnh-19056-1.html
x*a
29 楼
works, thanks. baozi sent.
c*5
30 楼
Levis这么喜欢BSO,那就别藏着掖着,藏头露尾,把真名公布一下,好让我们这些小人
物也真正敬仰拜读一下您的辉煌成就。
物也真正敬仰拜读一下您的辉煌成就。
t*e
31 楼
dynamic programming, matrix sum[i][j] = 1 indicate there is a subset of a0..
ai which sum up to j, then update like:
sum[i][j] = sum[i-1][j] || sum[i-1][j-vi]
until j==expected sum
ai which sum up to j, then update like:
sum[i][j] = sum[i-1][j] || sum[i-1][j-vi]
until j==expected sum
z*3
36 楼
咦 你都混出头啦
【在 l*****e 的大作中提到】
: 未删节版,但是不带字幕
: http://www.shuangtv.net/dy/nxnwmyqzdnh-19056-1.html
d*g
37 楼
将信将遗,试了一下,真不错!
p*m
38 楼
咖啡喷了一键盘。你赔我咖啡。
【在 s**********e 的大作中提到】
: 是这个吗?
: http://news.creaders.net/photo/newsViewer.php?nid=518762&id=115
【在 s**********e 的大作中提到】
: 是这个吗?
: http://news.creaders.net/photo/newsViewer.php?nid=518762&id=115
f*i
41 楼
求助:
我不小心将右边那半放了进去,结果机器被锁了
现在有什么办法能够恢复吗?
我不小心将右边那半放了进去,结果机器被锁了
现在有什么办法能够恢复吗?
t*u
49 楼
不用这么麻烦吧,不放sim卡可以免费打任何电话。。。
l*3
52 楼
可以可以。。。
g*y
57 楼
don't you think it's exponential solution?
Any way, I myself doubt if there's exist a polynomial solution.
【在 p*********9 的大作中提到】
: bool calculateSum(int[] A, int s, int sum)
: {
: if( sum < 0 || s < 0 ) return false;
: if( A[s] == sum )
: {
: printf(" %d ", A[s]);
: return true;
: }
: if( calculateSum(A, s-1, sum) ) return true;
: if( calculateSum(A, s-1, sum-A[s] )
Any way, I myself doubt if there's exist a polynomial solution.
【在 p*********9 的大作中提到】
: bool calculateSum(int[] A, int s, int sum)
: {
: if( sum < 0 || s < 0 ) return false;
: if( A[s] == sum )
: {
: printf(" %d ", A[s]);
: return true;
: }
: if( calculateSum(A, s-1, sum) ) return true;
: if( calculateSum(A, s-1, sum-A[s] )
c*x
61 楼
老太太尿炕~~
y*n
63 楼
有那么夸张吗?
private static Boolean isPrefix(String prefix, String s1) {
if(prefix.length()>s1.length())
return false;
for(int i=0; i
boolean t = prefix.charAt(i)==s1.charAt(i);
if (false==t)
return false;
else if (true==t&& i == prefix.length()-1)
return true;
}
return false;
}
【在 c*****z 的大作中提到】
: 第一题你写的什么算法,最简单得n^2算法?
:
: 个数
private static Boolean isPrefix(String prefix, String s1) {
if(prefix.length()>s1.length())
return false;
for(int i=0; i
boolean t = prefix.charAt(i)==s1.charAt(i);
if (false==t)
return false;
else if (true==t&& i == prefix.length()-1)
return true;
}
return false;
}
【在 c*****z 的大作中提到】
: 第一题你写的什么算法,最简单得n^2算法?
:
: 个数
l*z
64 楼
是调出键盘,上上下下左右左右,ABAB,开始
j*o
65 楼
老李估计周末要和老婆孩子去吃一顿拔费庆祝一下
y*n
66 楼
有那么夸张吗?
private static Boolean isPrefix(String prefix, String s1) {
if(prefix.length()>s1.length())
return false;
for(int i=0; i
boolean t = prefix.charAt(i)==s1.charAt(i);
if (false==t)
return false;
else if (true==t&& i == prefix.length()-1)
return true;
}
return false;
}
【在 c*****z 的大作中提到】
: 第一题你写的什么算法,最简单得n^2算法?
:
: 个数
private static Boolean isPrefix(String prefix, String s1) {
if(prefix.length()>s1.length())
return false;
for(int i=0; i
boolean t = prefix.charAt(i)==s1.charAt(i);
if (false==t)
return false;
else if (true==t&& i == prefix.length()-1)
return true;
}
return false;
}
【在 c*****z 的大作中提到】
: 第一题你写的什么算法,最简单得n^2算法?
:
: 个数
p*9
69 楼
don't know how to output those found numbers. But, all combination can be
found in the arrya B. BTW, it is the 0-1 knapsack problem. The time should
be O(n*sum).
void calculateSum(int[] A, int sum)
{
arrary B[n+1,sum+1];//suppose B has been defined.
for(i=1;i<=n;i++) B[i][0] = 0;
for(i=0;i<=sum;i++) B[0][i] = 0;
for(i=1..n)
{
for(w=0;w<=sum;w++)
{
if( A[i] > w ) B[i,w] = B[i-1, w];
else B[i,w] = max( A[i]+B[i-1,w-A[i]), B[i-1,w]);
}
}
}
with
【在 i********r 的大作中提到】
: this is a 0-1 knapsack problem which has been proved a NP problem. even with
: the same unit price.
found in the arrya B. BTW, it is the 0-1 knapsack problem. The time should
be O(n*sum).
void calculateSum(int[] A, int sum)
{
arrary B[n+1,sum+1];//suppose B has been defined.
for(i=1;i<=n;i++) B[i][0] = 0;
for(i=0;i<=sum;i++) B[0][i] = 0;
for(i=1..n)
{
for(w=0;w<=sum;w++)
{
if( A[i] > w ) B[i,w] = B[i-1, w];
else B[i,w] = max( A[i]+B[i-1,w-A[i]), B[i-1,w]);
}
}
}
with
【在 i********r 的大作中提到】
: this is a 0-1 knapsack problem which has been proved a NP problem. even with
: the same unit price.
o*e
80 楼
感觉到不是knapsack problem。knapsack problem 是在满足背包容量的情况下求最大
的utility。knapsack problem能转化成graph用动态规划来解。但是把它转化成graph
的时候用的是枚举法。而这个问题只是求满足条件的所有数组。
另外,我觉得这个问题不是一般的动态规划能解得。动态规划的目的是求一个最优解,
而这个问题只是问满足条件的解。如果这个问题时求在sum一定的情况下,找一个组成
这个sum的数的积最大,那么这个问题可能可以用constrained dynamic programming来
解。但是显然,对于面试写code,这是太难了。
【在 w******l 的大作中提到】
: google knapsack problem
:
: 个数
的utility。knapsack problem能转化成graph用动态规划来解。但是把它转化成graph
的时候用的是枚举法。而这个问题只是求满足条件的所有数组。
另外,我觉得这个问题不是一般的动态规划能解得。动态规划的目的是求一个最优解,
而这个问题只是问满足条件的解。如果这个问题时求在sum一定的情况下,找一个组成
这个sum的数的积最大,那么这个问题可能可以用constrained dynamic programming来
解。但是显然,对于面试写code,这是太难了。
【在 w******l 的大作中提到】
: google knapsack problem
:
: 个数
Q*e
82 楼
This is Subset sum problem, NP-complete
x*y
84 楼
Your program is to check whether the prefix of s1 is the string "prefix",
but what that guy said is to check whether the string "prefix" is in the
string "s1".
For the second problem, it's the subset sum problem, a special case of 0-1
knapsack problem and you can find the subset by tracing back the table...
It's pseudo-polynomial algorithm, which runs as O(n*Sum), where n is the length of
a...Tracing back table cost O(n) time...
//below just my program, probably not the best
//the key part of it
【在 y****n 的大作中提到】
: 有那么夸张吗?
: private static Boolean isPrefix(String prefix, String s1) {
: if(prefix.length()>s1.length())
: return false;
: for(int i=0; i :
: boolean t = prefix.charAt(i)==s1.charAt(i);
: if (false==t)
: return false;
: else if (true==t&& i == prefix.length()-1)
but what that guy said is to check whether the string "prefix" is in the
string "s1".
For the second problem, it's the subset sum problem, a special case of 0-1
knapsack problem and you can find the subset by tracing back the table...
It's pseudo-polynomial algorithm, which runs as O(n*Sum), where n is the length of
a...Tracing back table cost O(n) time...
//below just my program, probably not the best
//the key part of it
【在 y****n 的大作中提到】
: 有那么夸张吗?
: private static Boolean isPrefix(String prefix, String s1) {
: if(prefix.length()>s1.length())
: return false;
: for(int i=0; i
: boolean t = prefix.charAt(i)==s1.charAt(i);
: if (false==t)
: return false;
: else if (true==t&& i == prefix.length()-1)
a*g
86 楼
太復雜了
length of
【在 x***y 的大作中提到】
: Your program is to check whether the prefix of s1 is the string "prefix",
: but what that guy said is to check whether the string "prefix" is in the
: string "s1".
: For the second problem, it's the subset sum problem, a special case of 0-1
: knapsack problem and you can find the subset by tracing back the table...
: It's pseudo-polynomial algorithm, which runs as O(n*Sum), where n is the length of
: a...Tracing back table cost O(n) time...
: //below just my program, probably not the best
: //the key part of it
length of
【在 x***y 的大作中提到】
: Your program is to check whether the prefix of s1 is the string "prefix",
: but what that guy said is to check whether the string "prefix" is in the
: string "s1".
: For the second problem, it's the subset sum problem, a special case of 0-1
: knapsack problem and you can find the subset by tracing back the table...
: It's pseudo-polynomial algorithm, which runs as O(n*Sum), where n is the length of
: a...Tracing back table cost O(n) time...
: //below just my program, probably not the best
: //the key part of it
c*5
93 楼
这真是一个欢乐贴!
g*i
94 楼
如果只是说Prefix, 也就是说一定要从Soure String's 0 poition 开始, 这个是对的
。It's different from String.indexof(target), which is more difficult
because the 'target' can begin from any place of the source String. Taking a
look the source code of String.idnexof really helps. As below:
/**
* Code shared by String and StringBuffer to do searches. The source is
the character array being searched, and the target is
* the string being searched for.
*
* @param source the characters being searched.
【在 y****e 的大作中提到】
: 你这个明显不对。
。It's different from String.indexof(target), which is more difficult
because the 'target' can begin from any place of the source String. Taking a
look the source code of String.idnexof really helps. As below:
/**
* Code shared by String and StringBuffer to do searches. The source is
the character array being searched, and the target is
* the string being searched for.
*
* @param source the characters being searched.
【在 y****e 的大作中提到】
: 你这个明显不对。
o*e
95 楼
我躺床上看贴,被笑的做起来了。哈哈哈,你们这帮人
a*h
96 楼
I use dynamic programming to solve Q2. My solution required a sorted
integer array as input. The boolean array is the solution.
public static void main (String [] args) {
int [] intList = {1, 3, 5, 6, 8, 9, 11, 12};
boolean [] boolList = subsetSum(intList, 10);
System.out.println(Arrays.toString(intList));
System.out.println(Arrays.toString(boolList));
}
public static boolean [] subsetSum(int [] intList, int sum) {
if (su
integer array as input. The boolean array is the solution.
public static void main (String [] args) {
int [] intList = {1, 3, 5, 6, 8, 9, 11, 12};
boolean [] boolList = subsetSum(intList, 10);
System.out.println(Arrays.toString(intList));
System.out.println(Arrays.toString(boolList));
}
public static boolean [] subsetSum(int [] intList, int sum) {
if (su
f*h
97 楼
汉堡说:我中枪了吗?
相关阅读
老话题:旧硬盘如何处理? (转载)io.js版本帝啊...Go’s path to becoming a Top 10 if not Top 5 language一个pc只有一个NIC,能跟2个不同的subnet connect 吗? (转载)Google Glass sales halted but firm says kit is not dead有人上过coursera的compiler么?有人在Java/J2EE项目中用过多线程/concurrent吗?java jvm 问题2014我最喜爱的翻墙工具zz请教各路C++大神 为什么f(3) 输出是 'dd'c# 6 new features.一项技术的生命力有多久?重回首,看当年的帖子来点好东西:Awesome AngularJS今年国家自然科学一等奖有报酬,求人编程序还是awk牛B在不同版本的hdfs之间copy大量文件新的<Web技术日报 >有intellij 高手么 问2个java技巧