diff --git a/array/three_sum.dart b/array/three_sum.dart new file mode 100644 index 0000000..625b8e8 --- /dev/null +++ b/array/three_sum.dart @@ -0,0 +1,46 @@ +//Leetcode problem no. 15: https://leetcode.com/problems/3sum/description/ +//Time Complexity: O(N^2) +//Space Complexity: O(1) + +//Input: A list of integers +//Output: A list of lists containing all those integers whose sum end up to 0 + +import 'package:test/test.dart'; + +import '../sort/heap_Sort.dart'; + +List> threeSum(List l){ + List> ans=[]; + sort(l); + for(int i=0; i0) k--; + else{ + ans.add([l[i], l[j], l[k]]); + j++; + k--; + while(j