Skip to content

Instantly share code, notes, and snippets.

@a7me63azzab
Last active June 7, 2020 03:53
Show Gist options
  • Save a7me63azzab/28e6338554215828bd14f5c7c11b56b5 to your computer and use it in GitHub Desktop.
Save a7me63azzab/28e6338554215828bd14f5c7c11b56b5 to your computer and use it in GitHub Desktop.
Play with LeetCode [Dart] [ problem solving ]
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