-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday18.cs
More file actions
39 lines (33 loc) · 692 Bytes
/
Copy pathday18.cs
File metadata and controls
39 lines (33 loc) · 692 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
using System;
using System.Text;
using static System.Console;
class Palindrome
{
private StringBuilder stack;
private StringBuilder queue;
public Palindrome()
{
stack = new StringBuilder();
queue = new StringBuilder();
}
public void pushCharacter(char c)
{
stack.Append(c);
}
public void enqueueCharacter(char c)
{
queue.Append(c);
}
public char popCharacter()
{
char ret = stack[stack.Length - 1];
stack.Remove(stack.Length - 1, 1);
return ret;
}
public char dequeueCharacter()
{
char ret = queue[0];
queue.Remove(0, 1);
return ret;
}
}