一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 616|回复: 8
收起左侧

[实习] Twitter OA 求助!。 Java Python 大神请进!

[复制链接] |试试Instant~ |关注本帖
笑眯眯的白云 发表于 2016-10-31 10:52:52 | 显示全部楼层 |阅读模式

2011(1-3月)-[12]CS本科+fresh grad 无实习/全职 - 内推| 码农类实习@Twitterfresh grad应届毕业生

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

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x

An organism's DNA is responsible for how it looks, how it behaves as well as its physiology. Figuring out how genes mutate can help us understand alien evolution as well as treat earthly diseases better. It's the year 2056 & you've obtained a motherload of sequenced genetic material from a research laboratory on Mars. Interesting relationships can be found by studying how genetic sequences are related to one another through mutations. Your task is to write a method - findMutationDistance that takes in this genetic data bank as a large collection of sequences (bank) and the 2 sequences (start & end) whose mutation distance needs to be calculated. This method should return the shortestmutation distance between the two sequences - start and end. If, for whatever reason such a mutation is not possible, the method should return -1.
.鏈枃鍘熷垱鑷1point3acres璁哄潧

Constraints:
#1.Martian biological material contains genetic sequences that are all 8 characters in length. The only allowed characters in the sequence are the 4 nucleotide bases of a DNA strand - Adenine, Cytosine, Guanine & Thymine, represented by the letters 'A', 'C', 'T' & 'G'. For eg, 'AATTGGCC' represents a possible genetic sequence in the data bank.

#2. For a sequence to be a part of the mutation distance, it must contain all but 1 of the nucleotide bases as its preceding sequence in the same order AND be present in the bank of valid sequences. For eg. 'AATTGGCC' -> 'AATTGGCA' can be considered a valid mutation if 'AATTGGCA' is present in the bank. Another example of a valid mutation can be 'AATTGGCC' -> 'TATTGGCC' -> 'TTTTGGCC' -> 'TTTTGGCA' if 'TATTGGCC', 'TTTTGGCC' & 'TTTTGGCA' are present in the bank of valid genetic sequences. In this example, the mutation distance is 3, as it took 3 mutations to go from 'AATTGGCC' to 'TTTTGGCA'.

#3. You can assume that the bank will contain unique sequences, and the start sequence may or may not be a part of the bank.

可以用Java 或者Python 写 (我也是醉了,我是C++的, 竟然不能用C++写?)
  1. /*
  2. * Complete the function below.
  3. */

  4.     static int findMutationDistance(String start, String end, String[] bank) {. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷

  5. . 鍥磋鎴戜滑@1point 3 acres
  6.     }

复制代码




pbw3177311 发表于 2016-10-31 13:58:57 | 显示全部楼层
这题leetcode上有啊。
回复 支持 反对

使用道具 举报

 楼主| 笑眯眯的白云 发表于 2016-10-31 13:59:39 | 显示全部楼层
pbw3177311 发表于 2016-10-31 13:58-google 1point3acres
这题leetcode上有啊。

问题我把上面的答案输入了, testcase 4 & 5 过不了。 说超时。
回复 支持 反对

使用道具 举报

pbw3177311 发表于 2016-10-31 14:01:02 | 显示全部楼层
是word ladder的简化版。而且原题也加到leetcode上了。433的Minimum Genetic Mutation
回复 支持 反对

使用道具 举报

pbw3177311 发表于 2016-10-31 14:02:22 | 显示全部楼层
笑眯眯的白云 发表于 2016-10-31 13:59. 1point 3acres 璁哄潧
问题我把上面的答案输入了, testcase 4 & 5 过不了。 说超时。

那我不清楚了。我做Twitter没碰到这道题,只是在leetcode上做过,可以过leetcode的test。就是用的最原始的bfs
回复 支持 反对

使用道具 举报

 楼主| 笑眯眯的白云 发表于 2016-10-31 14:02:58 | 显示全部楼层
pbw3177311 发表于 2016-10-31 14:01
是word ladder的简化版。而且原题也加到leetcode上了。433的Minimum Genetic Mutation

对的, 不知道为什么 按照他们 的做法, test case 4 和5 超时。 你的超时了吗?
回复 支持 反对

使用道具 举报

pbw3177311 发表于 2016-10-31 14:03:49 | 显示全部楼层
笑眯眯的白云 发表于 2016-10-31 14:02. visit 1point3acres.com for more.
对的, 不知道为什么 按照他们 的做法, test case 4 和5 超时。 你的超时了吗?

我没碰到这道题。。。
回复 支持 反对

使用道具 举报

 楼主| 笑眯眯的白云 发表于 2016-10-31 14:24:14 | 显示全部楼层
pbw3177311 发表于 2016-10-31 14:03
我没碰到这道题。。。

你说为啥他不让cpp 写呢
回复 支持 反对

使用道具 举报

xietao0221 发表于 2016-10-31 14:31:41 | 显示全部楼层
BFS来做就好了
回复 支持 反对

使用道具 举报

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2016-12-4 10:16

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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