-
Notifications
You must be signed in to change notification settings - Fork 3
/
Double.java
48 lines (46 loc) · 1.12 KB
/
Double.java
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
39
40
41
42
43
44
45
46
47
48
import java.io.*;
import java.util.*;
public class Double
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String [] s = sc.nextLine().split(" ");
int size = s.length;
int arr[]= new int[size];
boolean found = false;
for(int i=0;i<size;i++)
{
arr[i] = Integer.parseInt(s[i]);
}
Arrays.sort(arr);
int mid = 0;
int target = 0;
int store = 0;
// System.out.println(arr[2]);
for(int i=0;i<size;i++)
{
int start = 0;
int end = size -1;
int ans=arr[i]*2;
while(start<=end)
{
mid = start + (end-start/2);
if(ans== arr[mid])
{
found = true;
break;
}
else if(ans > arr[mid])
{
start = mid +1;
}
else
{
end = mid -1;
}
}
}
System.out.println(found);
}
}