-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_1.java
79 lines (57 loc) · 1.35 KB
/
3_1.java
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//3.1:Describe how you could use a single array to implement three stacks.
//Todo: Should be replaced by generic class
public class Node {
private Node next;
private char data;
public Node(){
next = null;
data = "";
}
public Node(char ch){
next = null;
data = ch;
}
public char getData(){
return data;
}
private void setData(char ch){
data = ch;
}
public Node getNext(){
Node = next;
}
}
public class RemoveDuplicate {
//convert string into single unsorted linked list
public Node init(char[] content, int length){
Node head = new Node();
Node temp = head;
for(int i=0; i<length; i++){
temp.setData(content[i]);
System.out.printf(content[i])
temp = temp.getNext();
}
return head;
}
//method1: with buffer
public static void removeDuplicate1(){
}
//method2: without buffer
public static void removeDuplicate2(){
}
//public static
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("Please enter your string:");
String in = input.nextLine();
int length = in.length();
char[] content = in.toCharArray();
Node head = init(content, length);
System.out.println();
input.close();
}
}