We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 520ad81 commit e5f4d98Copy full SHA for e5f4d98
dart/0136-single-number.dart
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ int singleNumber(List<int> nums) {
3
+ int? val = null;
4
+ nums.sort();
5
+ int i = 0;
6
+ while (i < nums.length - 2) {
7
+ if (!(nums[i] != nums[i + 2] && nums[i] == nums[i + 1])) {
8
+ val = nums[i];
9
+ break;
10
+ } else {
11
+ i = i + 2;
12
+ }
13
14
+ if (val == null) {
15
+ val = nums[nums.length - 1];
16
17
+ return val;
18
19
+}
0 commit comments