-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoSum.java
More file actions
38 lines (26 loc) · 820 Bytes
/
Copy pathTwoSum.java
File metadata and controls
38 lines (26 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//Two sum.
import java.util.Scanner;
class TwoSum{
public int[] twosum_func(int[] nums,int target){
int n=nums.length;
return new int[]{};
}
public static void main(String args[]){
//Enter size of array.
Scanner obj=new Scanner(System.in);
System.out.print("Enter the size of array: ");
int size=obj.nextInt();
int nums[]=new int[size];
int n=nums.length;
//Enter numbers in array.
for(int i=0;i<n;i++){
System.out.print("Enter numbers for array: ");
nums[i]=obj.nextInt();
}
//Enter target.
System.out.print("Enter a target: ");
int target=obj.nextInt();
TwoSum obj2=new TwoSum();
obj2.twosum_func(nums,target);
}
}