Algorithm · Airbnb · Medium
You are given a document text together with a substitution table, and you need to produce a redacted copy of the document. Every replacement is computed against the original document only: text that a substitution writes into the output must never be examined or substituted again. Implement redact_document(text: string, phrases: string[], replacements: string[]) -> string. The arrays phrases and replacements always have the same length, and phrases[i] is to be replaced by…