TikTok VO Interview Question: Edit Distance Between 2 Strings With Dictionary-Based Cost

14 Views
No Comments

Edit distance between 2 strings with dictionary-based cost

This is a classic edit-distance variant where transforming one string into another uses insertion, deletion, and replacement operations, but each operation cost is determined by a dictionary-based rule rather than being fixed. The standard solution is dynamic programming: define the state as the minimum cost to convert one prefix into another, then transition through delete, insert, and replace operations while applying the given cost lookup. The main challenge is modeling the cost correctly and computing the global minimum over all prefix states.

END
 0