Skip to content

Commit e1997e8

Browse files
authored
Merge pull request neetcode-gh#2043 from alexprudhomme/0448-find-all-numbers-disappeared-in-an-array.cs
Create: 0448-find-all-numbers-disappeared-in-an-array.cs
2 parents 3737a86 + 31eb062 commit e1997e8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class Solution {
2+
public IList<int> FindDisappearedNumbers(int[] nums) {
3+
for(int i = 0; i < nums.Length; i++) {
4+
int index = Math.Abs(nums[i]) - 1;
5+
nums[index] = -Math.Abs(nums[index]);
6+
}
7+
List<int> result = new List<int>();
8+
for(int i = 0; i < nums.Length; i++) {
9+
if(nums[i] > 0) {
10+
result.Add(i + 1);
11+
}
12+
}
13+
return result;
14+
}
15+
}

0 commit comments

Comments
 (0)