注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
求大米啊求大米~~~!! 跪求大米
karat面试,自我介绍,先问了一些cs基础问题,我选的api/web 和 product issue。
然:- *
- We have some clickstream data that we gathered on our client's website. Using cookies, we collected snippets of users' anonymized URL histories while they browsed the site. The histories are in chronological order, and no URL was visited more than once per person.
- Write a function that takes two users' browsing histories as input and returns the longest contiguous sequence of URLs that appears in both.
- Sample input:
- /start
- user0 = ["/start", "/green", "/blue", "/pink", "/register", "/orange", "/one/two"]
- user1 = ["/start", "/pink", "/register", "/orange", "/red", "a"]
- user2 = ["a", "/one", "/two"]
- user3 = ["/pink", "/orange", "/yellow", "/plum", "/blue", "/tan", "/red", "/amber", "/HotRodPink", "/CornflowerBlue", "/LightGoldenRodYellow", "/BritishRacingGreen"]
- user4 = ["/pink", "/orange", "/amber", "/BritishRacingGreen", "/plum", "/blue", "/tan", "/red", "/lavender", "/HotRodPink", "/CornflowerBlue", "/LightGoldenRodYellow"]
- user5 = ["a"]
- user6 = ["/pink","/orange","/six","/plum","/seven","/tan","/red", "/amber"]
- Sample output:
- findContiguousHistory(user0, user1) => ["/pink", "/register", "/orange"]
- findContiguousHistory(user0, user2) => [] (empty)
- findContiguousHistory(user0, user0) => ["/start", "/green", "/blue", "/pink", "/register", "/orange", "/one/two"]
- findContiguousHistory(user2, user1) => ["a"]
- findContiguousHistory(user5, user2) => ["a"]
- findContiguousHistory(user3, user4) => ["/plum", "/blue", "/tan", "/red"]
- findContiguousHistory(user4, user3) => ["/plum", "/blue", "/tan", "/red"]
- findContiguousHistory(user3, user6) => ["/tan", "/red", "/amber"]
- n: length of the first user's browsing history
- m: length of the second user's browsing history
- */
- import java.io.*;
- import java.util.*;
- import javax.sound.sampled.SourceDataLine;
- public class Solution {
- public static void main(String[] argv) {
- String[] user0 = {"/start", "/green", "/blue", "/pink", "/register", "/orange", "/one/two"};
- String[] user1 = {"/start", "/pink", "/register", "/orange", "/red", "a"};
- String[] user2 = {"a", "/one", "/two"};
- String[] user3 = {"/pink", "/orange", "/yellow", "/plum", "/blue", "/tan", "/red", "/amber", "/HotRodPink", "/CornflowerBlue", "/LightGoldenRodYellow", "/BritishRacingGreen"};
- String[] user4 = {"/pink", "/orange", "/amber", "/BritishRacingGreen", "/plum", "/blue", "/tan", "/red", "/lavender", "/HotRodPink", "/CornflowerBlue", "/LightGoldenRodYellow"};
- String[] user5 = {"a"};
- String[] user6 = {"/pink", "/orange", "/six", "/plum", "/seven", "/tan", "/red", "/amber"};
- //System.out.println(calculateClicksByDomain(counts));
-
- System.out.println(findContiguousHistory(user0, user1));
- }
复制代码 求大米啊求大米~~~!! 跪求大米
|