Last active
June 7, 2020 03:53
-
-
Save a7me63azzab/28e6338554215828bd14f5c7c11b56b5 to your computer and use it in GitHub Desktop.
Play with LeetCode [Dart] [ problem solving ]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
List<int> result = twoSum([2, 7, 11, 15],9); | |
print(result); | |
} | |
List<int> twoSum(List<int> nums,int target){ | |
List<int> indices = []; | |
for(int i = 0; i< nums.length; i++){ | |
print("i : nums[$i]=> ${nums[i]}"); | |
if(i != nums.length -1){ | |
for(int j=i+1;j< nums.length;j++){ | |
if(j < nums.length){ | |
print("j : nums[$j]=> ${nums[j]}"); | |
print("=-=-==-=-=--=-=-="); | |
print(nums[i] + nums[j]); | |
if(nums[i] + nums[j] == target){ | |
indices = [i,j]; | |
} | |
} | |
} | |
} | |
} | |
return indices; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment