forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPinDuoDuo_2.java
More file actions
43 lines (37 loc) · 1.11 KB
/
Copy pathPinDuoDuo_2.java
File metadata and controls
43 lines (37 loc) · 1.11 KB
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
package BiShi;
import java.io.File;
import java.util.HashMap;
import java.util.Scanner;
/**
* @Classname PinDuoDuo_2
* @Description TODO
* @Date 19-7-28 下午1:48
* @Created by mao<[email protected]>
*/
public class PinDuoDuo_2 {
public static void main(String[] args) throws Exception{
Scanner sc=new Scanner(new File("/home/mao/workspace/java/src/BiShi/pinduoduo2"));
while (sc.hasNext()){
String t=sc.nextLine();
String[] v=t.split(" ");
HashMap<Character,Character> dict=new HashMap<>();
Character start=v[0].charAt(0);
Character over=v[0].charAt(0);
for(String s:v){
Character c1=s.charAt(0);
Character c2=s.charAt(s.length()-1);
dict.put(c1,c2);
}
Character end=null;
for(int i=0;i<v.length;i++){
end=dict.get(start);
start=end;
}
if(over==end){
System.out.println(true);
}else {
System.out.println(false);
}
}
}
}