Get Sequence
Learn this problemProblem statement
Data scientists at Amazon are working on a utility for genome sequencing algorithms. The utility finds anagram patterns in a pair of DNA sequence strings. A pair of DNA is special if they are anagrams after removing any number of occurrences of at most one character from each DNA sequence.
Given n pairs of DNA, for each pair, attempt to make them anagrams. Return a list of boolean values, one for each pair, where True means a pair is special.
Complete the function getSequence in the editor below.
getSequence has the following parameter(s):
String dna[n][2]: the pairs of DNA sequences.
The function returns boolean[n]: true if the pair is special, and false otherwise.
Function
getSequence(dna: String[][]) → boolean[]Examples
Example 1
dna = [["safddadfs", "famafmss"]]return = [true]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 2
dna = [["abcee", "acdeedb"], ["sljffsaje", "sljsje"]]return = [true, false]For pair 1, remove 'd' from the second string and leave the first string untouched.
For pair 2, dna1 contains 'f' and 'a' which are not in dna2. They cannot be anagrams after removing only one character from dna1.
Example 3
dna = [["abcdee", "abcde"]]return = [true]Remove one occurrence of 'e' from dna1.
Constraints
1 <= n <= 101 <= length of dna[i][0], dna[i][1] <= 10000- The strings in
dna[i][0]anddna[i][1]consist of lowercase English letters only.
More Amazon problems
- Find Maximum Total Amount (SDE I, Fungible :)OA · Seen Jul 2026
- Meeting Rooms IIPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · ONSITE INTERVIEW · Seen Jul 2026
- Count the Number of Complete ComponentsPHONE SCREEN · Seen Jul 2026
- Cousins in Binary Tree IIONSITE INTERVIEW · Seen Jul 2026
- Minimum Operations to Make an Array ContinuousONSITE INTERVIEW · Seen Jul 2026
- Vertical Order Traversal of a Binary TreeONSITE INTERVIEW · Seen Jul 2026
- HTTP Request RedirectionOA · Seen Jul 2026