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.
Some people have said they overcame the timeouts for test cases 1 to 10 by switching to faster languages. I have so far tried to solve this in python 3.6, using the following approaches:
Direct XOR operations
Creating a trie for each query, as suggested in the Topics
Accumulating tries where possible by reordering the queries, to eliminate duplicate insertions.
Re 3, for test case 0 for example, I made an algorithm to arrange queries in this order of lower and upper indices, so that I "grow" (in this case) 3 tries by starting with the narrowest range of indices and progressively widening them
This way the total number of trie insertions is equivalent to the insertions needed for only the final queries of each sequence [1,13], [6,10], [10,15]. I had high hopes for the 3rd approach, but alas test cases 1 to 10 still time out and only 0, 11, 12, 13 pass, just like approaches 1 and 2.
I can't think of any further possible refinements to the algorithm, so I am wondering if python is just too slow to overcome the timeouts. Has anyone passed cases 1 to 10 with a python solution?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
XOR key
You are viewing a single comment's thread. Return to all comments →
Some people have said they overcame the timeouts for test cases 1 to 10 by switching to faster languages. I have so far tried to solve this in python 3.6, using the following approaches:
Re 3, for test case 0 for example, I made an algorithm to arrange queries in this order of lower and upper indices, so that I "grow" (in this case) 3 tries by starting with the narrowest range of indices and progressively widening them
This way the total number of trie insertions is equivalent to the insertions needed for only the final queries of each sequence [1,13], [6,10], [10,15]. I had high hopes for the 3rd approach, but alas test cases 1 to 10 still time out and only 0, 11, 12, 13 pass, just like approaches 1 and 2.
I can't think of any further possible refinements to the algorithm, so I am wondering if python is just too slow to overcome the timeouts. Has anyone passed cases 1 to 10 with a python solution?