Hello everyone,
I am a biologist that is a relatively new to programming. This isn't for homework, however I would like to efficiently write a piece of a program that finds the number of unique elements in a sorted array. My array has over 200,000+ elements in it, so it would be silly to brute force the whole thing, especially because the array is sorted.
Example:
@array = (0,0,0,1,1,1,1, 2,3,3);
Would return:
0: 3
1: 4
2: 1
3: 2
Any suggestions? I don't need the entire code if it is against the rules, but I would like an idea of how to program this.
I am a biologist that is a relatively new to programming. This isn't for homework, however I would like to efficiently write a piece of a program that finds the number of unique elements in a sorted array. My array has over 200,000+ elements in it, so it would be silly to brute force the whole thing, especially because the array is sorted.
Example:
@array = (0,0,0,1,1,1,1, 2,3,3);
Would return:
0: 3
1: 4
2: 1
3: 2
Any suggestions? I don't need the entire code if it is against the rules, but I would like an idea of how to program this.
Comment