Untitled

mail@pastecode.io avatar
unknown
java
a month ago
454 B
1
Indexable
Never
class HelloWorld {
    public static int targget(int arr[] ,int target){
        for(int i=0;i<arr.length;i++){
            for(int j=i+1;j<arr.length;j++){
                if (arr[i]+arr[j]==target){
                    System.out.println(i+","+j);
                }
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] arr={2,71,7,14};
        int target =16;
        targget(arr,target);
    }
}
Leave a Comment