Question: A DNA sequence is represented by a string of lowercase letters. Given a pair of DNA sequences, if the scientist is able to remove any
A DNA sequence is represented by a string of lowercase letters. Given a pair of DNA sequences, if the scientist is able to remove any number of a letter in sequence and any number of a letter in sequence to make the strings anagrams, then the sequences are similar.
Given n pairs of DNA sequences, for each pair, attempt to find if they are similar. Return a list of boolean values where booleani indicates for the i'th pair.
Function Description
Complete the function getSequence in the editor below.
getSequence has the following parameters:
String dnan : the pairs of DNA sequences.
Returns
booleann : 'true' if the pair is special, and 'false' otherwise
Example :
Input: dna safddadfs "famafmss"
Output: true
Explanation:
The strings are anagrams after removing all the occurrences of character d from s and character m from t Return True
Note: It is not required that all instances of a character be removed. For example, given 'aab' and ba one a can be removed from 'aab' to leave ab
Example :
Input: dna abcee "acdeedb"sljffsajej "sljsje"
Output: true false
Explanation:
For pair remove b from the second string and leave the first string untouched.
For pair dna contains f and a which are not in dna They cannot be anagrams after removing only a character from dna
Constraints:
n
length of dnai dnai
The strings in dna and dna consist of lowercase English letters only.
Complete the following implementation in Java
import java.util.;
import java.io;
import java.lang.;
public class Solution
public boolean getSequenceString dna
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
