FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/Code-Forces/src/StoTConverter.java at master · javaarchive/Java · GitHub
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
javaarchive
/
Java
Public archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
3
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
Java
/
Code-Forces
/
src
/
StoTConverter.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (43 loc) · 1.49 KB
Breadcrumbs
Java
/
Code-Forces
/
src
/
StoTConverter.java
Copy path
File metadata and controls
46 lines (43 loc) · 1.49 KB
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
38
39
40
41
42
43
44
45
46
import
java
.
util
.*;
import
java
.
util
.
stream
.
Collectors
;
public
class
StoTConverter
{
public
static
void
main
(
String
[]
args
) {
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
N
=
sc
.
nextInt
();
sc
.
nextLine
();
for
(
int
run
=
0
;
run
<
N
;
run
++) {
String
s
=
sc
.
nextLine
(),
t
=
sc
.
nextLine
(),
p
=
sc
.
nextLine
();
ArrayList
<
Character
>
needed
=
new
ArrayList
<
Character
>();
System
.
out
.
println
(
"s:"
+
s
+
"
\n
"
+
"t:"
+
t
+
"
\n
"
+
"p:"
+
p
);
try
{
int
min
=
Integer
.
min
(
s
.
length
(),
t
.
length
());
for
(
int
i
=
0
;
i
<
min
;
i
++) {
if
(!(
s
.
charAt
(
i
) ==
t
.
charAt
(
i
))) {
throw
new
Exception
(
"SOLUTION REQUIRES REORDER"
);
}
}
for
(
int
i
=
0
;
i
<
t
.
length
();
i
++) {
//System.out.println("add "+i);
needed
.
add
(
t
.
charAt
(
i
));
}
System
.
out
.
println
(
"End Result: "
+
needed
);
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++) {
needed
.
remove
(
needed
.
indexOf
(
s
.
charAt
(
i
)));
}
System
.
out
.
println
(
"Letters needed: "
+
needed
);
List
<
Character
>
chars
=
p
.
chars
()
// IntStream
.
mapToObj
(
e
-> (
char
)
e
)
// Stream<Character>
.
collect
(
Collectors
.
toList
());
//System.out.println("Letters to find: "+needed);
System
.
out
.
println
(
"Letters to be used before: "
+
chars
);
for
(
char
c
:
needed
) {
//chars.remove(Character.valueOf(c));
chars
.
remove
(
chars
.
indexOf
(
c
));
}
System
.
out
.
println
(
"Letters to be used after: "
+
chars
);
System
.
out
.
println
(
"YES"
);
}
catch
(
Exception
e
) {
System
.
out
.
println
(
"NO "
+
e
.
getLocalizedMessage
());
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL