tag:blogger.com,1999:blog-2597841815280998418.post7206151113662250972..comments2024-03-12T06:45:01.935+01:00Comments on This Thread: Hackerrank Tries: ContactsMannyhttp://www.blogger.com/profile/07393063644320426727noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2597841815280998418.post-59349083309139222712018-02-03T13:24:13.729+01:002018-02-03T13:24:13.729+01:00Your script works alright, good job!
Just a minor...Your script works alright, good job!<br /><br />Just a minor point, I don't like much the try-except in the 'find' branch of the code, I would explicitly check the existence of the item in the dictionary instead.<br /><br />I push your code on github and modify the post to take note of your solution. Thank you.Mannyhttps://www.blogger.com/profile/07393063644320426727noreply@blogger.comtag:blogger.com,1999:blog-2597841815280998418.post-76854692940526289572018-02-02T16:17:01.125+01:002018-02-02T16:17:01.125+01:00How about this?
-------------------------
match = ...How about this?<br />-------------------------<br />match = set()<br />count = dict()<br />for i in range(int(input())):<br /> op = input().split(' ')<br /> if op[0] == 'add':<br /> contact = list(op[1])<br /> for j in range(len(op[1])):<br /> word = ''.join(contact[:j + 1])<br /> if word in match:<br /> count[word] Anonymousnoreply@blogger.com