FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaProb/SortAnUnsortArray.java at main · Warlord27/JavaProb · GitHub
Warlord27
/
JavaProb
Public
Notifications
You must be signed in to change notification settings
Fork
9
Star
13
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaProb
/
SortAnUnsortArray.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (22 loc) · 823 Bytes
Breadcrumbs
JavaProb
/
SortAnUnsortArray.java
Copy path
File metadata and controls
26 lines (22 loc) · 823 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
public
class
SortAnUnsortArray
{
// Merge sort of two array 2️⃣ 🎇
public
static
void
main
(
String
[]
args
) {
// Scanner sc = new Scanner(System.in);
int
arr1
[] = {
1
,
3
,
5
,
7
,
9
,
11
,
137
,
458
,
896
},
arr2
[] = {
2
,
4
,
6
,
8
,
10
,
12
,
14
};
int
arr3
[] =
new
int
[
arr1
.
length
+
arr2
.
length
];
int
k
=
0
,
r
=
0
,
c
=
0
;
while
(
r
<
arr1
.
length
&&
c
<
arr2
.
length
) {
if
(
arr1
[
r
] <
arr2
[
c
])
arr3
[
k
++] =
arr1
[
r
++];
else
arr3
[
k
++] =
arr2
[
c
++];
}
while
(
r
<
arr1
.
length
)
arr3
[
k
++] =
arr1
[
r
++];
while
(
c
<
arr2
.
length
)
arr3
[
k
++] =
arr2
[
c
++];
for
(
int
i
=
0
;
i
<
arr3
.
length
;
i
++) {
System
.
out
.
println
(
arr3
[
i
]);
}
}
}
Back
|
FazBrowse Home
|
New Git URL