FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/uber.java at main · VirajPatidar/Java-Programs · GitHub
VirajPatidar
/
Java-Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
uber.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (33 loc) · 789 Bytes
Breadcrumbs
Java-Programs
/
uber.java
Copy path
File metadata and controls
37 lines (33 loc) · 789 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
util
.
Arrays
;
public
class
uber
{
static
boolean
isPowerOfTwo
(
int
n
)
{
if
(
n
==
0
)
return
false
;
while
(
n
!=
1
)
{
if
(
n
%
2
!=
0
)
return
false
;
n
=
n
/
2
;
}
return
true
;
}
static
int
pair
(
int
a
[]) {
int
c
=
0
;
Arrays
.
sort
(
a
);
int
sum
=
0
;
for
(
int
i
=
0
;
i
<
a
.
length
-
1
;
i
++) {
for
(
int
j
=
1
;
j
<
a
.
length
;
j
++) {
sum
=
a
[
i
] +
a
[
j
];
if
(
isPowerOfTwo
(
sum
))
c
++;
}
}
return
c
;
}
public
static
void
main
(
String
[]
args
) {
int
a
[] = {
1
, -
1
,
2
,
3
};
int
n
=
uber
.
pair
(
a
);
System
.
out
.
println
(
n
);
}
}
Back
|
FazBrowse Home
|
New Git URL