//Checking the string is palindrome or not by using stack and queue
class Palindrome
{
public static void main(String args[])
{
String str=”madam”;
Queue<Charcter> q=new LinkedList<>();
Stack<Character> s=new Stack();
for(char ch:str.toCharArray())//ch=m
{
q.add(ch);//m
s.push(ch);//m
}
boolean isPalindrome=true;
while(!q.isEmpty())//false
{
if(q.remove()!=s.pop())
{
isPalindrome=false;
break;
}
}
if(isPalindrome)//true
System.out.println(str +”is a palindrome”);
else
System.out.println(str +”is not a palindrome”);
}}