Company: Zomato
Difficulty: medium
Question 16: Get Lexicographically Smallest String A data scientist is working on a project where they need to train a language model to recognize certain patterns in text data. The model requires a specific set of characters as input to learn from. However, some of the characters needed for training are missing from the dataset, represented in the form of a string called dataToBeGenerated . To acquire these missing characters, the data scientist has a tool that can generate multiple copies of a given string. However, the tool can only generate strings of a fixed length, n , and it only accepts one input string to generate missing data. Each string generated by the tool incurs a cost, and the more copies of strings generated, the higher the cost. The goal is to minimize the cost while ensuring the data contains all the required characters. The task is to find the lexicographically smallest input string that, when fed into the data generation tool, produces datasets containing all the r