-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
52 lines (43 loc) · 1.38 KB
/
test.java
File metadata and controls
52 lines (43 loc) · 1.38 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
44
45
46
47
48
49
50
51
52
package com.wang.code.one;
import java.util.*;
import java.util.Stack;
import java.util.concurrent.LinkedBlockingQueue;
/**
* @author WANGJJ
* @date 2020/04/15cd
*/
public class test {
public static void main(String[] args) {
LinkListQueue<Integer> linkListQueue = new LinkListQueue<>();
linkListQueue.enqueue(4);
linkListQueue.enqueue(3);
linkListQueue.enqueue(5);
linkListQueue.enqueue(2);
System.out.println(linkListQueue.max(linkListQueue.getFirst()));
String a = "wangjunjie";
String[] strings = a.split("");
for (String s: strings) {
System.out.println(s);
}
}
public boolean isValid(String s) {
String[] strings = s.split("");
Stack<String> stack = new Stack<String>();
Map<String, String> hashMap = new HashMap();
hashMap.put(")", "(");
hashMap.put("]", "[");
hashMap.put("}", "{");
for(String symbol:strings) {
if ("(".equals(symbol) || "[".equals(symbol) || "{".equals(symbol)){
stack.push(symbol);
} else if (
")".equals(symbol) || "]".equals(symbol) || "}".equals(symbol)
) {
if(!stack.pop().equals(hashMap.get(symbol))){
stack.push(symbol);
}
}
}
return stack.isEmpty();
}
}