[text] two sum

Viewer

  1. class Solution {
  2.     public int[] twoSum(int[] nums, int target) {
  3.         int lngth = nums.length;
  4.         int i,j = 0;
  5.         for (i = 0; i < lngth -1; i++) {
  6.            for (j = 1; j < lngth; j++) {
  7.                if (nums[i] + nums[j] == target) {
  8.                    break;
  9.                }
  10.            }
  11.         }   
  12.     int[] result = {i,j};
  13.     return result;    
  14.     }    
  15. }

Editor

You can edit this paste and save as new:


File Description
  • two sum
  • Paste Code
  • 24 Jun-2021
  • 396 Bytes
You can Share it: