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 ed984b5 commit 4b9a4e3Copy full SHA for 4b9a4e3
dart/0001-two-sum.dart
@@ -0,0 +1,14 @@
1
+// Time Complexity: O(n)
2
+// Space Complexity: O(n)
3
+
4
+class Solution {
5
+ List<int> twoSum(List<int> nums, int target) {
6
+ var map = Map<int, int>();
7
+ for (int i = 0; i < nums.length; i++) {
8
+ var x = target - nums[i];
9
+ if (map.containsKey(x)) return [map[x]!, i];
10
+ map[nums[i]] = i;
11
+ }
12
+ throw "";
13
14
+}
0 commit comments