Last active
April 12, 2021 20:33
-
-
Save Ezeji/16edfbb5f5a01b2a9d3d2d98cebab6bd to your computer and use it in GitHub Desktop.
This algorithm focuses on removing array duplicates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int RemoveArrayDuplicate(int[] nums) | |
{ | |
int arrayLength = 0; | |
for (int i = 0; i < nums.Length; i++) | |
{ | |
if (nums[i] == nums[i++]) | |
{ | |
arrayLength = arrayLength + 1; | |
} | |
} | |
return arrayLength; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @meekg33k
Thank you really for your efforts and this initiative. It is really a great vision that would have massive impact on the tech ecosystem by providing a learning opportunity for persons like myself who are life-long learners. Well done to you and your team!
I also want to thank you for the special mention on your blog as well as your feedback for improvement through this medium, it means a lot to me.
My question as regards handling null parameter passed to the function for a robust solution is, can such scenario also be taken care of by using a try-catch code construct, in other words, writing a function that performs its intended operation and handle every other out of bound edge cases using exception handling ?