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.
Thanks for the idea... but i have one doubt... for instance take input:
4 5
2 8 3 7
Here, total no. of pairs :
2 8 = divide
3 8 = not divide
3 7 = divide
2 3 = divide
8 7 = divide
2 7 = not divide
so, Answer should be 2 which is case with (3,8) and (2,7)
Now, according to your idea... lets i am using array
so,
Now here, as showing my loop will go through 2 index...
but as k/2 (5/2) so, max of a[2] and a[3] is 2 and thatsit....
resulting my answer is 2 only.... but it should be 4 as we are counting total pair which are evenly divisble
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Non-Divisible Subset
You are viewing a single comment's thread. Return to all comments →
Thanks for the idea... but i have one doubt... for instance take input: 4 5 2 8 3 7 Here, total no. of pairs : 2 8 = divide 3 8 = not divide 3 7 = divide 2 3 = divide 8 7 = divide 2 7 = not divide
so, Answer should be 2 which is case with (3,8) and (2,7) Now, according to your idea... lets i am using array so,
Now here, as showing my loop will go through 2 index... but as k/2 (5/2) so, max of a[2] and a[3] is 2 and thatsit.... resulting my answer is 2 only.... but it should be 4 as we are counting total pair which are evenly divisble