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
|
602 Discussions
|
Please Login in order to post a comment
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.
I wrote a recursive algorithm in python. It works, but it times out for test cases 12-14. Can anyone tell me why and how to fix it?