Question: Write a method called isPalindrome that accepts a queue of integers as a parameter and returns true if the numbers in the queue are the
Write a method called isPalindrome that accepts a queue of integers as a parameter and returns true if the numbers in the queue are the same in reverse order. For example, if the queue stores [3, 8, 17, 9, 17, 8, 3], your method should return true because this sequence is the same in reverse order. If the queue stores [3, 17, 9, 4, 17, 3], your method would return false because this sequence is not the same in reverse order (the 9 and 4 in the middle don’t match). The empty queue should be considered a palindrome. Your method must restore the parameter queue to its original state before returning. Use one stack as auxiliary storage.
Step by Step Solution
3.32 Rating (185 Votes )
There are 3 Steps involved in it
public boolean is Palindrome Queue q Stack s ... View full answer
Get step-by-step solutions from verified subject matter experts
