We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Abbreviation
Abbreviation
Sort by
recency
|
603 Discussions
|
Please Login in order to post a comment
tricky question. the naive dynamic programming 2D matrix method takes O(a.size()^2 * b.size()), which will likely give time out, but with modification can do it in O(a.size() * b.size()) time
js recursive
js non recursive
Python3 solution using a candidate solution method. Starting from a root candidate "" (empty string), iterate over the letters of a. At each letter, iterate over the candidates, taking the following actions to form the next set of candidates: 1. propagate candidate, i.e. do not add current letter and retain candidate (string) as-is. 2. fork candidate, i.e. add current letter to create a new candidate. 3. terminate candidate, e.g. when the letter must be added (b/c it is uppercase) but adding the letter makes the candidate invalid.