由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Yodle 面试题 Triangle 答对能有面试机会
相关主题
career cup 150第五版10.3 中numberOfInts为什么要除以8?问一道interview street 上的题
这里人多,请问Java如何读取需要登录的网页的内容贴个自己的答案:Binary Tree Max Path Sum
也发面经问一个java的函数调用问题
问一道Amazon的老题java concurrence 例子
谁能给个Serialization/Deserialization of a Binary Tree Java版完整code?大牛帮我看一段code
请帮我看下这道coding exercise? 那个L家店面的帖子, 怎么没了?
two questions网上很多blog show算法结果是个错的作者压根没验证过
string permutation,怎么处理重复字母?[合集] 微软面试题一道
相关话题的讨论汇总
话题: int话题: file话题: string话题: index
进入JobHunting版参与讨论
1 (共1页)
j**7
发帖数: 143
1
http://www.yodlecareers.com/puzzles/triangle.html
我的答案不对 (665321)。
public static void main(String[] args) {
// TODO Auto-generated method stub

File file = new File("triangle.txt");
try
{
BufferedReader in = new BufferedReader(new FileReader(file));
String line;
int value=Integer.parseInt(in.readLine().trim());
int index=0;

while ((line = in.readLine()) != null) {

String [] temp=line.split("[ ]");
int a=Integer.parseInt(temp[index]);
int b=Integer.parseInt(temp[index+1]);
if(b>a)
{
index=index+1;
value+=b;
}
else
{
value+=a;
}
}
System.out.println(value);//665321
in.close();
}catch(IOException e )
{

}
}
A*****i
发帖数: 3587
2
别想了,前年我就做对了,依然没拿到面试
除非第二个杂技团的游戏也解出来
这个题典型的DP
j**7
发帖数: 143
3

第一题怎么做?

【在 A*****i 的大作中提到】
: 别想了,前年我就做对了,依然没拿到面试
: 除非第二个杂技团的游戏也解出来
: 这个题典型的DP

j**7
发帖数: 143
4
明白了。
p*****2
发帖数: 21240
5
这个公司怎么样呀
B********t
发帖数: 147
6
是732506吗

));

【在 j**7 的大作中提到】
: http://www.yodlecareers.com/puzzles/triangle.html
: 我的答案不对 (665321)。
: public static void main(String[] args) {
: // TODO Auto-generated method stub
:
: File file = new File("triangle.txt");
: try
: {
: BufferedReader in = new BufferedReader(new FileReader(file));
: String line;

d*******3
发帖数: 58
7

我试了下,是732506,这题不就是leetcode triangle那题么

【在 B********t 的大作中提到】
: 是732506吗
:
: ));

j**7
发帖数: 143
8
结果:732506
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("triangle.txt");
try
{
BufferedReader in = new BufferedReader(new FileReader(file));
String line;

List list=new ArrayList();

while ((line = in.readLine()) != null) {

String [] temp=line.split("[ ]");
int [] a=new int [temp.length];
for(int i=0;i {
a[i]=Integer.parseInt(temp[i]);
}
list.add(a);

}
for(int i=list.size()-2;i>=0;i--)
{
int [] current=list.get(i);
int [] prev=list.get(i+1);
for(int j=0;j {
if(prev[j]>prev[j+1])
{
current[j]+=prev[j];
}
else
{
current[j]+=prev[j+1];
}

}
}
System.out.println(list.get(0)[0]);
in.close();
}catch(IOException e )
{

}
}
e***s
发帖数: 799
9
Leetcode有啊
h********0
发帖数: 74
10
not find out the second with google, would you help

【在 A*****i 的大作中提到】
: 别想了,前年我就做对了,依然没拿到面试
: 除非第二个杂技团的游戏也解出来
: 这个题典型的DP

l***i
发帖数: 1309
11
I did triangle 3 years ago and immediately got an email from them. Sadly
they do not hire interns ...
The answer to triangle can be found in yahoo answer.
1 (共1页)
进入JobHunting版参与讨论
相关主题
[合集] 微软面试题一道谁能给个Serialization/Deserialization of a Binary Tree Java版完整code?
问道看到的面试题请帮我看下这道coding exercise
问一个anagram的题two questions
问一道JAVA面试题目string permutation,怎么处理重复字母?
career cup 150第五版10.3 中numberOfInts为什么要除以8?问一道interview street 上的题
这里人多,请问Java如何读取需要登录的网页的内容贴个自己的答案:Binary Tree Max Path Sum
也发面经问一个java的函数调用问题
问一道Amazon的老题java concurrence 例子
相关话题的讨论汇总
话题: int话题: file话题: string话题: index