Need some help with a little coding problem.
I need to check if it is a Palindrome using a queue and a stack, by implementing a method that tests whether a sequence of numbers is a palindrome, that is, equal to the sequence in reverse.
the code in [...] is My Code, while everything else is unchangeable any help is appreciated.
Code:
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
public class QueueStackUtil
{
public static boolean isPalindrome(int[] values)
{
Queue<Integer> queue = new LinkedList<Integer>();
Stack<Integer> stack = new Stack<Integer>();
for (int s : values)
{
// insert s into the queue and stack
[//*MyCode//ins instack
s[++queue]=values;
//ins in queue
s[++stack]=values;]
}
while (queue.size() > 0)
{
[MyCode// remove an element from the queue
if(!isPaindrome()){
for(int i=0; i<tail;i++)
queue[i] = queue[i+1];
tail--;
}
// remove an element from the stack
if(!isPalindrome()) stack--;
// compare the removed elements
if(stack==queue)
!isPalindrome]
}
return true;
}
}