Return true if the string is a palindrom, I have to use a queue and a stck to do this, "qu" is the queue and "st" is the stack. does anyone see whats wrong with this. A palindrom is a word that reads the same front and back.
publicboolean isPal(String s)
{
stack st=new stack();
Queue qu=new Queue();
String x;
for(int i=0; i<s.length(); ++i)
{
x = String.valueOf(s.charAt(i));
qu.enqueue(x);//pushes it on the top of the queue
}
for(int v=s.length()-1; v>=0 ; --v)
{
x = String.valueOf(s.charAt(v));
if(x==qu.peek())//peek just returns the top item.
{
System.out.println("I got here");
st.push(qu.dequeue());//dequeue pops it off the queue and returns it.
}
}
returntrue;
}