Codechef Encoding January'20

Правка en1, от _nathan_drake_, 2020-01-30 23:00:50

Can someone tell me why did I have TLE in one approach but got ac with a huge time margin for the second approach. https://www.codechef.com/viewsolution/29264170 https://www.codechef.com/viewsolution/29262311

For the first approach I stored all the strings in a unordered set. Then , for each string s1 in the set I checked it with other strings . If a string matches prefix of s1 , then I recur for the string s1 — prefix . Base case will be when the current string s1 matched totally with a prefix. Then I return 1, else 0.

For the second approach I stored all the strings in a unordered set. Then , for each string s1 in the set , I checked if there exists a string that matches a particular length prefix. If yes, then I recur for the string s1 — prefix .

Why is the time limit difference . Am I missing something.

Теги #string matching, #strings, #running time, #timelimit

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский _nathan_drake_ 2020-01-30 23:00:50 873 Initial revision (published)