Write a method called isPalindrome that accepts a queue of integers as a parameter and returns true

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: