Return Every Matching Decryption
Reported by candidates from Duolingo's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Duolingo OA, reported in April 2026, is trying to reverse-map the encrypted string back to characters. Values collide, so that path explodes. This is a variant of the classic encrypter problem, but decrypt now returns every matching dictionary string instead of a count. Duplicates stay, order stays. If you've seen the original, don't paste the old solution. If you blank on the details, StealthCoder is the invisible safety net running during the live assessment. The trick is simple once you see it, and it's a hash table problem at heart.
The problem
Build an encrypter from unique one-character keys, their two-character values, and a plaintext dictionary. Different keys may map to the same encrypted value. Process every row [method, word] in operations: encrypt: map each character of word. If any character is unmapped, the encryption is the empty string. decrypt: return every dictionary occurrence whose full encryption equals word, rather than returning a count. The result contains one row per operation. An encrypt row contains exactly its one encryption string. A decrypt row contains matching dictionary strings in their original dictionary order; repeated dictionary occurrences are retained. If none match, that row is empty. Function processEncrypterMatches(keys: String[], values: String[], dictionary: String[], operations: String[][]) → String[][] Examples Example 1 keys = ["a","b","c","d"] values = ["ei","zf","ei","am"] dictionary = ["abcd","acbd","adbc","badc","dacb","cadb","cbda","abad"] operations = [["encrypt","abcd"],["decrypt","eizfeiam"]] return = [["eizfeiam"],["abcd","abad"]] The encryption is unchanged from the base exercise. Decrypt now returns the two matching plaintext strings themselves, in dictionary order. Example 2 keys = ["a","b"] values = ["xy","xy"] dictionary = ["a","b","a"] operations = [["decrypt","xy"],["encrypt","c"]] return = [["a","b","a"],[""]] All three dictionary occurrences match xy. Encrypting an unmapped character returns the empty string. Constraints 1 <= keys.length == values.length <= 26. Every key is a distinct lowercase English character represented as a one-character string. Every value contains exactly two lowercase English characters; values need not be unique. 1 <= dictionary.length <= 100; repeated dictionary strings are allowed. 1 <= operations.length <= 100. An encrypt word has length at most 2000. A decrypt word has positive even length at most 200.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Don't decode. Encrypt every dictionary word once in the constructor and store a map from encrypted string to a list of the original words, appended in dictionary order. Then decrypt is a single lookup that returns that list, or an empty list if the key is missing. That handles duplicate values like a and c both mapping to ei, because both words land under the same encrypted key. It also keeps repeated dictionary entries, since you append every occurrence. The pitfalls: forgetting that a dictionary word with an unmapped character encrypts to empty and must be skipped, not stored under an empty key. Also return a copy, and return [""] for a failed encrypt, not an empty row. Encrypt is a straight character lookup. Total cost is tiny at these constraints. If the details slip under the clock, StealthCoder can lay out this map-of-lists approach on screen while you're live in the OA.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Return Every Matching Decryption cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Duolingo's OA.
Duolingo reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Return Every Matching Decryption FAQ
What's the trick in this Duolingo encrypter problem?+
Precompute. Encrypt every dictionary word up front and group the originals under their encrypted string in a hash map of lists. Decrypt becomes a lookup. Trying to invert the mapping fails because multiple keys share the same two-character value.
How is this different from the classic Encrypter and Decrypter problem?+
The classic version returns a count of matching dictionary words. This one returns the actual strings, in original dictionary order, with repeated occurrences kept. So you store lists instead of counters, and the append order matters.
What edge cases break most first attempts?+
Unmapped characters. Encrypting one returns an empty string, and a dictionary word containing one must not be stored. Also watch the output shape: a failed encrypt returns a row with one empty string, while a failed decrypt returns an empty row.
Should I worry about time complexity here?+
Not much. Dictionary is at most 100 words, operations at most 100, and encrypt words reach 2000 characters. Precomputing once and doing O(1) map lookups per decrypt is more than fast enough. Just build the result with a string builder or list join.
How do I prepare for this in 48 hours?+
Write the original encrypter solution from scratch, then modify it to store lists. Test with Example 2, where duplicates and shared values both appear. Practice the hash map of lists pattern until you can type it without thinking.