Can anyone explain the time complexity of this solution and how this beats 100% of the solution? Isn't the time complexity should be n^2? So how this so fast?
class Solution {
public int[] twoSum(int[] nums, int target) {
for(int i = 1; i < nums.length; i++){
for(int j = i; j < nums.length; j++){
int sum = nums[j] + nums[j - i];
if(sum == target){
return new int[]{j , j - i};
}
}
}
return null;
}
}