由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Google 需要bug free 么?
相关主题
F家电面:group AnagramsFind shortest substring that is only occurring once. in Given String(Medallia面试题)
问一个Anagram的参考程序Anagrams有面试碰到过么?
Dream company Onsite被搞了(少量面经)请问我写的这个代码哪可以改进一下
Leetcode第30题真心不容易google phone interview
leetcode 438的难度 是不是标错了?问个anagram的题目啊
报个微软的Offer问个anagram的问题
facebook telephone interview from careercup一道G家店面题
问一个 String array sorting 的题。LC anagrams题目有问题吧?
相关话题的讨论汇总
话题: pend话题: founddict话题: var话题: pstart
进入JobHunting版参与讨论
1 (共1页)
x*********1
发帖数: 23
1
google 电面被拒了, 题目是 check 一个 String s 的 anagram 是否为 另一个
string t的 substring. 给的方法是 先得出 所有 s 的 anagram 然后 在check 是否
其中之一 为 t的 subString。 不知道这个做法做有什么问题? 之后在 eclipse 上测
了下 代码, 发现有几个 typo 和 方法名用错了, 比如 insert 写成了 add。这种问
题是挂的原因么? 感觉code 一多 又不在编译器里,又没太多检查时间,做到毫无瑕
疵真心很不容易啊。
m**********4
发帖数: 774
2
一点想法, 不知道对不对:
不需要generate所以的permutation。给一个hash(s),比如rolling hash,但每个位置
给的权重一样。在t上做kp,所需要的complexity只是t的长度。为了防止false
positive, 可以多用几个HASH FUNCTION。



【在 x*********1 的大作中提到】
: google 电面被拒了, 题目是 check 一个 String s 的 anagram 是否为 另一个
: string t的 substring. 给的方法是 先得出 所有 s 的 anagram 然后 在check 是否
: 其中之一 为 t的 subString。 不知道这个做法做有什么问题? 之后在 eclipse 上测
: 了下 代码, 发现有几个 typo 和 方法名用错了, 比如 insert 写成了 add。这种问
: 题是挂的原因么? 感觉code 一多 又不在编译器里,又没太多检查时间,做到毫无瑕
: 疵真心很不容易啊。

l******6
发帖数: 340
3
You didn't give the answer they want.. Which is more important than bug free
x*********1
发帖数: 23
4
请能仔细说说么? 或者 类似的参考资料? 我在做之前跟面试官确认了一下可以按我
那个方法做嘛, 他说没问题, 请问挂的原因会是算法不够高效么?还是因为code不够
干净呢

【在 m**********4 的大作中提到】
: 一点想法, 不知道对不对:
: 不需要generate所以的permutation。给一个hash(s),比如rolling hash,但每个位置
: 给的权重一样。在t上做kp,所需要的complexity只是t的长度。为了防止false
: positive, 可以多用几个HASH FUNCTION。
:
: 否

x*********1
发帖数: 23
5
我在写之前跟面试官确认了是否可以用我说的那个方法啊?面试官说可以,之后也没问
我是否能够优化?

free

【在 l******6 的大作中提到】
: You didn't give the answer they want.. Which is more important than bug free
l******6
发帖数: 340
6
Your method is working. But not as good as they expect so they say OK but
don't move on with you.

【在 x*********1 的大作中提到】
: 我在写之前跟面试官确认了是否可以用我说的那个方法啊?面试官说可以,之后也没问
: 我是否能够优化?
:
: free

d**********x
发帖数: 4083
7
sliding window.



【在 x*********1 的大作中提到】
: 我在写之前跟面试官确认了是否可以用我说的那个方法啊?面试官说可以,之后也没问
: 我是否能够优化?
:
: free

x*********1
发帖数: 23
8
既然这样的话还让我写什么啊,浪费时间么不是。如果需要更加高效的算法话可以跟我
说啊,然后我可以再考虑一下嘛

【在 l******6 的大作中提到】
: Your method is working. But not as good as they expect so they say OK but
: don't move on with you.

d**********x
发帖数: 4083
9
i don't like this either.
if they directly tell you that there is an O(N) algorithm, you may realize
it immediately.

【在 x*********1 的大作中提到】
: 既然这样的话还让我写什么啊,浪费时间么不是。如果需要更加高效的算法话可以跟我
: 说啊,然后我可以再考虑一下嘛

x*********1
发帖数: 23
10
不知道想的对不对,如果这样的话,那么面试官想要的都是做过类似题的候选人了,除
非知道最优解,然后直接给出答案, 否则, 你给出个solution,面试官不满意也让你
写不就是存心挂人么。

【在 d**********x 的大作中提到】
: i don't like this either.
: if they directly tell you that there is an O(N) algorithm, you may realize
: it immediately.

相关主题
报个微软的OfferFind shortest substring that is only occurring once. in Given String(Medallia面试题)
facebook telephone interview from careercupAnagrams有面试碰到过么?
问一个 String array sorting 的题。请问我写的这个代码哪可以改进一下
进入JobHunting版参与讨论
l******6
发帖数: 340
11
That is why we go over leetcode over and over....

【在 x*********1 的大作中提到】
: 不知道想的对不对,如果这样的话,那么面试官想要的都是做过类似题的候选人了,除
: 非知道最优解,然后直接给出答案, 否则, 你给出个solution,面试官不满意也让你
: 写不就是存心挂人么。

x*********1
发帖数: 23
12


【在 l******6 的大作中提到】
: That is why we go over leetcode over and over....
x*********1
发帖数: 23
13
任重道远啊。

【在 l******6 的大作中提到】
: That is why we go over leetcode over and over....
m**********g
发帖数: 153
14
sliding window是否这样解:
<1>expect_occur[256] for s
<2>real_occur[256]
whenever real_occur[t[i]] > expect_occur[t[i]], clear real_occur and start
from i+1 again.

【在 d**********x 的大作中提到】
: sliding window.
:
: 否

d**********x
发帖数: 4083
15
idea is similar but not that simple....
try this problem on leetcode:
http://oj.leetcode.com/problems/substring-with-concatenation-of
and you will see if you understood it correctly.

【在 m**********g 的大作中提到】
: sliding window是否这样解:
: <1>expect_occur[256] for s
: <2>real_occur[256]
: whenever real_occur[t[i]] > expect_occur[t[i]], clear real_occur and start
: from i+1 again.

d**********x
发帖数: 4083
16
ok... anyways, 2 points:
1. we may not know where exactly i is, so we need to scan from the start of
the window until we encounter a character same as t[x]
2. when we encounter a char not in anagram, we just reset all records

【在 m**********g 的大作中提到】
: sliding window是否这样解:
: <1>expect_occur[256] for s
: <2>real_occur[256]
: whenever real_occur[t[i]] > expect_occur[t[i]], clear real_occur and start
: from i+1 again.

P****2
发帖数: 197
17
最短SNIPPETS变形吧,一样2指针2字典,O(n)扫过去
public bool IsAnagramSubString(string str, string anagram)
{
var pStart = 0;
var pEnd = 0;
var targetDict = anagram.GroupBy(p => p)
.ToDictionary(
g => g.Key,
g => g.Count()
);
var targetTotalNum = targetDict.Values.Sum();
var foundDict = targetDict.ToDictionary(p => p.Key, p => 0);
var foundTotalNum = 0;
while (pEnd < str.Length)
{
var c = str[pEnd];
if (!targetDict.ContainsKey(c))
{
foundTotalNum = 0;
foundDict = targetDict.ToDictionary(p => p.Key, p => 0);
}
else
{
foundDict[str[pEnd]]++;
foundTotalNum++;
while (foundDict[c] > targetDict[c])
{
foundDict[str[pStart]]--;
foundTotalNum--;
pStart++;
}
}
pEnd++;
if (foundTotalNum == targetTotalNum) return true;
}
return false;
}
k*****m
发帖数: 14
18
跟leetcode这道题是一样的,最后检测下那个结果是不是跟input size一样,O(n)
http://oj.leetcode.com/problems/minimum-window-substring/
g*********e
发帖数: 14401
19
事实就是这样

【在 x*********1 的大作中提到】
: 不知道想的对不对,如果这样的话,那么面试官想要的都是做过类似题的候选人了,除
: 非知道最优解,然后直接给出答案, 否则, 你给出个solution,面试官不满意也让你
: 写不就是存心挂人么。

s******i
发帖数: 236
20
ls一些人略装B
只能说lz遇到奇葩面试官了
patpat
1 (共1页)
进入JobHunting版参与讨论
相关主题
LC anagrams题目有问题吧?leetcode 438的难度 是不是标错了?
LC: anagram为何忽略single element?报个微软的Offer
finds all repeated substrings in the string --- YAHOO interview questionfacebook telephone interview from careercup
请教一道题目问一个 String array sorting 的题。
F家电面:group AnagramsFind shortest substring that is only occurring once. in Given String(Medallia面试题)
问一个Anagram的参考程序Anagrams有面试碰到过么?
Dream company Onsite被搞了(少量面经)请问我写的这个代码哪可以改进一下
Leetcode第30题真心不容易google phone interview
相关话题的讨论汇总
话题: pend话题: founddict话题: var话题: pstart