1. Code Question 1
Amazon's software team utilizes several algorithms to maintain data integrity, one of which targets the encoding of symmetrical names. Symmetrical names are unique in that they read identically in both directions, similar to palindromes in language parlance.
The chief aim of the algorithm is to rearrange the characters in the original symmetrical name according to these criteria:
- The rearranged name is a reshuffled version of the original symmetrical name.
- The restructured name should be symmetrical as well.
- This restructured name should be lexicographically smallest among all its symmetric permutations.
Given an initial symmetrical name that contains only lowercase English characters, compute the encoded name.
A string s
is considered to be lexicographically smaller than the string t
of the same length if the first character in s
that differs from that in t
is smaller. For example, "abcd"
is lexicographically smaller than "abdc"
but larger than "abad"
.
Note that the output encoded name could match the original name if it's already the smallest lexicographically.
2. Code Question 2
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.
Example Given, n = 1, pair and strings dna1 = "safddadfs"
and dna2 = "famafmss"
.
The strings are anagrams after removing all the occurrences of character 'd' from dna1
and character 'm' from dna2
. 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
.
Function Description
Complete the function getSequence
in the editor below.
getSequence
has the following parameter(s):
string dna[n][2]
: the pairs of DNA sequences.
Returns
A list of booleans, True
if the pair is special, and False
otherwise.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.