diff --git a/csharp/0026-remove-duplicates-from-sorted-array.cs b/csharp/0026-remove-duplicates-from-sorted-array.cs new file mode 100644 index 000000000..03159918b --- /dev/null +++ b/csharp/0026-remove-duplicates-from-sorted-array.cs @@ -0,0 +1,13 @@ +public class Solution { + public int RemoveDuplicates(int[] nums) { + var left = 1; + for(var right = 1; right < nums.Length; right++) { + if(nums[right] != nums[right-1]) { + nums[left] = nums[right]; + left++; + } + } + + return left; + } +} \ No newline at end of file