Skip to content

Commit 31eb062

Browse files
committed
Create: 0448-find-all-numbers-disappeared-in-an-array.cs
1 parent fa2d4c3 commit 31eb062

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)