F**********r 发帖数: 237 | 1 也是版上来的。。。 不知道这个题目给的数字3在这里有什么帮助。最naive就是n-1
common sequence.不好。
要么就是都生成3的组合,然后看哪个出现的最多。如果logfile entry多的话,明显也
不好。
有什么好的办法没?
Given a log file, which contains a series of websites, which the user has
visited, find the most frequent path of 3 websites.
e.g: If this is a log file
A B C D E
A C D B E
C D E B A
A C D E B
C D E A B |
s*****y 发帖数: 897 | 2 You have good question everyday. I like it. Keep going.
【在 F**********r 的大作中提到】 : 也是版上来的。。。 不知道这个题目给的数字3在这里有什么帮助。最naive就是n-1 : common sequence.不好。 : 要么就是都生成3的组合,然后看哪个出现的最多。如果logfile entry多的话,明显也 : 不好。 : 有什么好的办法没? : Given a log file, which contains a series of websites, which the user has : visited, find the most frequent path of 3 websites. : e.g: If this is a log file : A B C D E : A C D B E
|
s*******n 发帖数: 344 | |
F**********r 发帖数: 237 | 4 不太懂。。。
【在 s*******n 的大作中提到】 : use 2 hashtable I think
|
l*****g 发帖数: 685 | 5 你的问题就是前阵子讨论的Amazon的最popular三连击问题
不过你的log file跟原来题目中的不一样,amazon问题中的log format是多user的,如
下:
useId page timestamp
1 A t1
2 A t2
1 C t3
1 E t4
2 B t5
3 A t6
3 D t7
...
所以需要用两个hashtable.
而你的log是单一user的, 简单一点,用一个hashtable就够了:
1) 读取log的每一行,(假定你的log中的每一行表示不连续的访问记录),extract其
中所有三连击
譬如,A B C D E ==> "A B C", "B C D", "C D E"
2) 用三连击的string作为hashtable 的 key, 三连击的count 作为value
3) 读完所有line, 最后凭count给hashtable的entry排序就可以了
【在 F**********r 的大作中提到】 : 也是版上来的。。。 不知道这个题目给的数字3在这里有什么帮助。最naive就是n-1 : common sequence.不好。 : 要么就是都生成3的组合,然后看哪个出现的最多。如果logfile entry多的话,明显也 : 不好。 : 有什么好的办法没? : Given a log file, which contains a series of websites, which the user has : visited, find the most frequent path of 3 websites. : e.g: If this is a log file : A B C D E : A C D B E
|
F**********r 发帖数: 237 | 6 嗯,如果是连续的话是很make sense。8过貌似原题给的example 答案是cde,也就是可
能不连续(比如在第二行)
【在 l*****g 的大作中提到】 : 你的问题就是前阵子讨论的Amazon的最popular三连击问题 : 不过你的log file跟原来题目中的不一样,amazon问题中的log format是多user的,如 : 下: : useId page timestamp : 1 A t1 : 2 A t2 : 1 C t3 : 1 E t4 : 2 B t5 : 3 A t6
|
g***s 发帖数: 3811 | 7 你理解错了。第二行的CDE没有被counted。
【在 F**********r 的大作中提到】 : 嗯,如果是连续的话是很make sense。8过貌似原题给的example 答案是cde,也就是可 : 能不连续(比如在第二行)
|
F**********r 发帖数: 237 | 8 原来是这样,多谢!
【在 g***s 的大作中提到】 : 你理解错了。第二行的CDE没有被counted。
|