Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
leaky
arr
Your code has a bug.
Let say g=3, m=3, n=4
Result: [0, 3] // Should be[0,0]
Let say g=5, m=5, n=6
Resutl: [0,6] // Should be [0,0]
Your function will getting problem when g=m and n > m + 1 (or more)
Your problem code is here:
if (candidates[1] - candidates[0] == (long long)g) {
return candidates;
For the first iteration
candidate[1] will fill with first prime number
but candidate[0] is 0.
So, when first prime - 0 == g (your code wrong here)
// you should start compare candidate[0] and candidate[1] after these two values are filled
The description it too simple until made me confuse. Is the function requires remove all the duplicate values and return that array/list or need to count how many values are distinct and return that number. If just need to tell the number of distict values why made this function to return a pointer.