boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 贡献G家电面面经
相关主题
lintcode delete digits怎么做?
问个java hashcode的题
[面试题求教]remove common phrases from each sentence
leetcode 上 wordladderII 求教
Word ladder II 感觉算法已经是最优了,但是过不了大测试,能不能帮忙看看?
微软有组在招new grad software engineer吗?
一道面试题(integer to binary string)
share int2roman and roman2int java version
4sum o(n^2)超时
星期一福利:某公司店面题
相关话题的讨论汇总
话题: digits话题: string话题: phonewords话题: hashset话题: list
进入JobHunting版参与讨论
1 (共1页)
f**********2
发帖数: 2401
1
类似电话面板的一道题,输入是一个List digits, 一串数字,每个数字对应
可以翻译为3个character。翻译后的结果的pertutation是否可以组成一个单词,如果
可以,保存为结果集,输出。
Example:
2--> 'a','b','c'
8--> 't','u','c'
如果输入是228,
228 --> 'aat','abu',...
可以用2个函数
digits2char(int d)
isWord(String u)
输出是'aat','abu',...中所有的是单词的结果。
Set phoneWords(List digits){
}
自己有点紧张,题目不难,答得不太好,小毛病很多。供大家参考
g*****g
发帖数: 212
2
确实不难,此题如果你定义一个数组,而不是各种if else
string[] mapping{"abc",...}
你的 code会简洁很多,也不容易犯错。
x****g
发帖数: 1512
3
有啥特殊要求?
public static HashSet phoneWords(List digits)
{
HashSet words = new HashSet();
StringBuilder sb = new StringBuilder(digits.Count);
phoneWords(digits, 0, words, sb);
return words;
}
public static void phoneWords(List digits, int index, HashSet<
string> words, StringBuilder sb)
{
if (index == digits.Count)
{
string word = sb.ToString();
if (IsWord(word))
{
words.Add(word);
}
}
else
{
foreach (char ch in digits2char(digits[index]))
{
sb.Append(ch);
phoneWords(digits, index + 1, words, sb);
sb.Length--;
}
}
}
f**********2
发帖数: 2401
4
update:
没能通过,悲剧了。。。recruiter说了一些话还是挺安慰的,不过还是自己问题吧,
学艺不精。
1 (共1页)
进入JobHunting版参与讨论
相关主题
星期一福利:某公司店面题
发个evernote的code challenge
FB 面筋
这个题目难度在leetcode里算什么
问道google面试题
问个考古的题
好不容易写了个bug free, 可是被说会秒据, 帮看看
一道电面题,分享下, 这个题应该用哪几个data structure?
Java programming question
问个string combination的问题
相关话题的讨论汇总
话题: digits话题: string话题: phonewords话题: hashset话题: list