Skip to content

Commit 8fbf104

Browse files
Merge pull request #2976 from bansalgaurav852/main
create 0136-single-number.dart
2 parents 06a92f5 + e63b453 commit 8fbf104

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

dart/0070-climbing-stairs.dart

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
int climbStairs(int n) {
3+
int first=0;
4+
int second=1;
5+
int res=1;
6+
for(int i=0;i<n;i++){
7+
res=first+second;
8+
first=second;
9+
second=res;
10+
}
11+
return res;
12+
}
13+
}

dart/0136-single-number.dart

+19
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)