Advertisement
Andrix883

1. Two Sum

Dec 6th, 2024 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | Source Code | 0 0
  1. class Solution {
  2.     public int[] twoSum(int[] nums, int target) {
  3.         for(int i = 0; i < nums.length; i++)
  4.             for(int j = i+1; j < nums.length; j++)
  5.                 if(nums[i] + nums[j] == target)
  6.                     return new int[] {i, j};
  7.         return new int[2];
  8.     }//twoSum
  9. }//class
Tags: leetcode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement