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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Algebra
  4. Sherlock and Queries
  5. Discussions

Sherlock and Queries

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

Sort 61 Discussions, By:

votes

Please Login in order to post a comment

  • ccbrown
    7 years ago+ 1 comment

    Got my 30 points, but I thought the modulus part could have been clearer. Someone else suggested it here and got down-voted, but I'll suggest it again anyways: Making the sample case actually demonstrate the effects of the modulus would make it a much better sample.

    13|
    Permalink
  • netineti
    8 years ago+ 1 comment

    For each multiple say x, of 1 in 1 to N, we have to multiply A[x] with C[1] p1 times.

    For each multiple say x, of 2 in 1 to N, we have to multiply A[x] with C[2] p1 times.

    for clarity, should probably be:

    For each multiple x of B[1] in x = 1 to N, multiply A[x] by C[1].

    For each multiple y of B[2] in y = 1 to N, multiply A[x] by C[2].

    6|
    Permalink
  • Kingofthekings
    7 years ago+ 0 comments

    WOW such a nice question felt really good after solving it !!

    4|
    Permalink
  • Tuxdude
    7 years ago+ 0 comments

    This was a good problem to solve - worked out my brain quite a bit :)

    In the end though, like everyone pointed out, the final algorithm is quite simple if you understand what all the multiplication operations are doing. :-)

    2|
    Permalink
  • yakamoz
    7 years ago+ 2 comments

    I wrote a code whose complexity is approximately O(M*log(N)) in avarage case.(in best case O(M)). When integers of B arrays become small number such as 15-20, complexity approach O(N*M) which is worst case. What is the trick of this question? Make worst case and avarage case complexity linearithmic time or better?

    1|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature