注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
今天做了CF家的欧艾。和地里其他的贴子说的一样,就是两道题,一共两个小时。
如果你用过他家产品,就知道这两题就是他们自家产品的一些功能所需求的算法。
1. Shortest Code Length: 这个就是除去 line comment (//) 和 block comment(/**/)之后所有的字符字数。CF网站上有一些challenge就是看谁写的代码最短。
2. Plagiarism Check: 这题是看两段代码之间,是不是除了变量名不一样,其他的都一样。如果是的话就是抄袭。
感觉如果没见过这两题,要跑过所有的test case可能还有一定的挑战,幸亏看了地里之前的面经。
/** * Ever so often on Codefights, a user tries to submit a duplicate solution * they copied from someone else. Generally these are pretty easy to detect * and block. However, it gets trickier when you have a duplicate solution * with some variables renamed to avoid getting caught. * * The cheating usually happens as follows: in a text editor the * "Find and replace" function is applied to all occurrences of some * variable name A that consists of letters, digits, underscores, and starts * with a non-digit character (since it's a variable name), to change it to * some other variable name B that fulfills the same constraints. * * It would appear that after applying this "Find and replace" procedure * multiple times it would be impossible to detect duplicates, but this /div>// Example // // For // // source = ["int a = 2;", // "int b = 47;/*37;*///41;", // "int c = 3/*4//5*/;", // the output should be shortestSolutionLength(source) = 34. // // In the 1st line there are 7 non-space characters; // In the 2nd line there are 2 comments - /*37;*/ and //41;. Besides those there are only 8 non-space characters; // The 3rd line contains 1 comment - /*4//5*/, and 7 non-space characters; // The last line of code has 1 comment - /*a /* b / c*/, and 12 non-space characters; // In summary, there are 7 + 8 + 7 + 12 = 34 countable characters
public int shortestSolutionLength(String[] source) {
}
|