Skip to content

Instantly share code, notes, and snippets.

@Ezeji
Last active April 12, 2021 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ezeji/16edfbb5f5a01b2a9d3d2d98cebab6bd to your computer and use it in GitHub Desktop.
Save Ezeji/16edfbb5f5a01b2a9d3d2d98cebab6bd to your computer and use it in GitHub Desktop.
This algorithm focuses on removing array duplicates.
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;
}
@Ezeji
Copy link
Author

Ezeji commented Apr 12, 2021

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment