📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 1
跳转到指定楼层
上一主题 下一主题
收起左侧

CodeFights OA

全局:

2017(10-12月) 码农类General 硕士 全职@CodeFights - 网上海投 - 在线笔试  | | Other | 其他

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

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
         * isn't the case. Your goal is to implement an algorithm that compares two
         * code snippets and determines whether one of them could be produced from
         * the other using the above-described approach.
         *
         * Note. Here is a formal definition of how "Find and replace" function
         * works. When searching for string A to replace all of its occurrences in
<
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
/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) {

}





上一篇:Quantcast实习一面
下一篇:BB onsite 汇总
🔗
 楼主| michaelwu 2018-1-3 04:57:58 | 只看该作者
全局:
#update: 两道题的所有test cases 都过了,然后就莫名的挂了。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表