AMAZON Coding Question – Solved

4 Live
Data scientists at Amazon are working on a utility for detecting similar passwords in their security systems. The utility finds anagram patterns in pairs of passwords. A pair of passwords is considered similar if they are anagrams after removing any number of occurrences of at most one character from each password. Given n pairs of passwords, for each pair, attempt to make them anagrams. Return a list of boolean values, one for each pair, where True means a pair is similar. Example Given n = 1, and the strings password1 = "safddadfs" and password2 = "famafmss". The strings are anagrams after removing all the occurrences of character 'd' from the first password and character 'm' from the second password. 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 findSimilarPasswords in the editor below. findSimilarPasswords has the following parameter(s): string password[n][2]: the pairs of passwords. Returns bool[n]: "true" if the pair is special, and "false" otherwise Constraints Β· 1 ≀ n ≀ 10 Β· 1 ≀ |password[i][0]|, |password[i][1]| ≀ 10,000 Β· The strings in password1 and password2 consist of lowercase English letters only. Sample Case 0 Input n = 2 password1 = "abcee", password2 = "acdeedb" password1 = "sljffsaje", password2 = "sljsje" Output [True, False] Explanation For pair 1, remove 'd' from the second string and leave the first string untouched. For pair 2, password1 contains 'f' and 'a' which are not in password2. They cannot be anagrams after removing only 1 character from password1. Sample Case 1 Input n = 1 password1 = "abcdee", password2 = "abcde" Output [True] Explanation Remove one occurrence of 'e' from password1.

Asked in: AMAZON

Image of the Question

Question Image Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Stacey is coordinating a beach clean-up event with her university's Women in ST… |
| Perform a series of operations on a given array of integers. Each operation con… |
| To be efficient, Amazon must optimally distribute parcels among their delivery … |
| The Amazon warehouse receives a multitude of packages every day, each assigned … |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |
| Amazon Books is a retail store that sells the newly launched novel "The Story o… |