Skip to main content

Posts

Showing posts with the label Day 18: Queues and Stacks Hackerrank Solution Java

Day 18: Queues and Stacks Hackerrank Solution Java

 Day 18: Queues and Stacks Hackerrank Solution Java For Explanation Check Video: Sample Input racecar Sample Output The word, racecar, is a palindrome. Code: import  java.io.*; import  java.util.*; public   class  Solution {      // Write your code here.//racecar     Stack<Character> st =  new  Stack<>();     Queue<Character> q =  new  LinkedList<>();      void  pushCharacter( char  ch){         st.push(ch); //race     }      void  enqueueCharacter( char  ch){         q.add(ch); //ecar     }      char  popCharacter(){          return  st.pop(); //c    ...