Skip to content

Commit

Permalink
Merge pull request neetcode-gh#2043 from alexprudhomme/0448-find-all-…
Browse files Browse the repository at this point in the history
…numbers-disappeared-in-an-array.cs

Create: 0448-find-all-numbers-disappeared-in-an-array.cs
  • Loading branch information
tahsintunan authored Jan 16, 2023
2 parents 3737a86 + 31eb062 commit e1997e8
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 e1997e8

Please sign in to comment.