We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f3af52 commit 6a817a0Copy full SHA for 6a817a0
MissingNumber.dart
@@ -0,0 +1,20 @@
1
+// Leetcode problem link: https://leetcode.com/problems/missing-number/
2
+
3
+class Solution {
4
5
+// initializing an iterator at first to avoid initializing it each time inside the loop as the loop iterates
6
+var i = 0;
7
8
+// this function will be called with a list to return the missing number
9
+int missingNumber(List nums) {
10
+for (; i <= nums.length; i++) {
11
+ // checking if the list doesn't contain i
12
+ if (!nums.contains(i)) {
13
+ return i;
14
+ }
15
+}
16
17
+return 0;
18
19
20
0 commit comments