it showing me runtime error java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3 at line 5, Solution.twoSum
class Solution {
public int[] twoSum(int[] nums, int target) {
for(int i=0;i<nums.length;i++){
int result=nums[i]+nums[i+1];
if(result==target){
return new int[]{i,i+1};
}
}
throw new IllegalArgumentException("No two sum solution");
}
}