-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnePointThree.java
More file actions
49 lines (38 loc) · 930 Bytes
/
OnePointThree.java
File metadata and controls
49 lines (38 loc) · 930 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
39
40
41
42
43
44
45
46
47
48
49
// Nicole Kulakowski
// Question 1.3
// Given two strings, write a method to decide if one is a permutation
// of the other.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class OnePointThree{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String one, two;
public static void main(String[] args){
OnePointThree OPT = new OnePointThree();
OPT.dothing();
}
private String sort(String s){
char[] content = s.toCharArray();
java.util.Arrays.sort(content);
return new String(content);
}
private boolean permutation(String s, String t){
if(s.length() != t.length())
{
return false;
}
return sort(s).equals(sort(t));
}
public void dothing()
{
try{
one = br.readLine();
two = br.readLine();
} catch(IOException e){
one = "error";
two = "error";
}
System.out.println(permutation(one,two));
}
}