BackhardM Mixed Topics Cred Goldman Sachs

Lexicographically Smallest Replacement String Solution

Problem Statement

Given a string `text` and a dictionary `synonyms` where each key is a word and its corresponding value is a list of synonyms, find the lexicographically smallest string that can be formed by replacing the words in `text` with their synonyms from `synonyms`.

Constraints

  • The input string s contains only alphanumeric characters and spaces.
  • The dictionary wordDict can contain multiple synonyms for a single word.
  • All the words in wordDict are unique and do not have any duplicates.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free