Sherlock and Queries

Sort by

recency

|

62 Discussions

|

  • + 0 comments

    One more hint. If B[i]==1, you need to multiply every A on all C's product. It can be done in O(N+M).

  • + 0 comments

    I am getting timeout in four testcases, 9, 10, 12, 13...any suggestions. My code https://www.hackerrank.com/challenges/sherlock-and-queries/submissions/code/33184473

  • + 0 comments

    I will give a hint to other people trying to get through this by themselves: it's a trivial improvement of the algorithm that one immediately sees, followed by a sanitization of the input. The second part is less obvious, as some people - including myself - don't see it as part of the initial algorithm.

  • + 0 comments

    Great question. I first tried this problem months ago but was note able to solve it completely. Now I did. :-)

  • + 1 comment

    if j % B[i] == 0 then

    Shouldn't this be:

    if A[j] % B[i] == 0 then

    I get the expected output only when I make that change