Skip to content

Commit

Permalink
Create: 0448-find-all-numbers-disappeared-in-an-array.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme committed Jan 16, 2023
1 parent fa2d4c3 commit 31eb062
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions csharp/0448-find-all-numbers-disappeared-in-an-array.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Solution {
public IList<int> FindDisappearedNumbers(int[] nums) {
for(int i = 0; i < nums.Length; i++) {
int index = Math.Abs(nums[i]) - 1;
nums[index] = -Math.Abs(nums[index]);
}
List<int> result = new List<int>();
for(int i = 0; i < nums.Length; i++) {
if(nums[i] > 0) {
result.Add(i + 1);
}
}
return result;
}
}

0 comments on commit 31eb062

Please sign in to comment.