Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d38e7e2

Browse files
Solution to The DNA matching problem
Problem Given:A forensic lab wants to know whether a deceased person’s DNA matches a set of known relatives. It is known that the closest relatives will have most of the DNA matching, and as the relationship becomes farther, the matching genes will be lesser. For this, the DNA pattern of the deceased is given and the DNA pattern of 10 likely relatives are given. Write a program to identify the family of the deceased.
1 parent bf1fb2e commit d38e7e2

File tree

1 file changed

+38
-0
lines changed
  • Company Specific Interview Questions/Google/Solutions/Cpp

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
// your code goes here
6+
7+
string Original;
8+
string copy[10];
9+
int match[10];
10+
cin>>Original;
11+
for (int i=0;i<10;i++)
12+
cin>>copy[i];
13+
14+
int count_max=0;
15+
16+
for(int j=0;j<10;j++)
17+
{
18+
int count=0;
19+
for (int i=0 ;i<Original.length();i++)
20+
{
21+
if (copy[j][i]==Original[i])
22+
{
23+
count++;
24+
}
25+
}
26+
match[j]=count;
27+
28+
if(count_max<match[j])
29+
count_max=match[j];
30+
}
31+
32+
for( int i=0;i<10;i++)
33+
{
34+
if(count_max == match[i])
35+
cout<<copy[i]<<" Is Family\n";
36+
}
37+
return 0;
38+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /