Блог пользователя _nathan_drake_

Автор _nathan_drake_, история, 5 лет назад, По-английски

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.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится