HackerRank Day 18 Queues and Stacks 30 days of code solution YASH PAL, 31 July 2024 In this HackerRank Day 18 Queues and Stacks 30 days of the code problem statement, we need to check whether a given string is a palindrome number or not. rest of the things already defined. Problem solution in Python 2 programming. class Solution: # Write your code here stack = [] queue = [] def __init(self): self.stack = [] self.queue = [] def pushCharacter(self, ch): self.stack.insert(0, ch) def popCharacter(self): return self.stack.pop(0) def enqueueCharacter(self, ch): self.queue.append(ch) def dequeueCharacter(self): return self.queue.pop(0) Problem solution in Python 3 programming. class Solution: def __init__(self): self.stack = [] self.queue = [] def pushCharacter(self, ch): self.stack.append(ch) def enqueueCharacter(self, ch): self.queue.append(ch) def popCharacter(self): return self.stack.pop() def dequeueCharacter(self): return self.queue.pop(0) Problem solution in java programming. public class Solution { LinkedList<Character> queue = new LinkedList(); LinkedList<Character> stack = new LinkedList(); public void pushCharacter(char ch){ stack.push(ch); } public void enqueueCharacter(char ch){ queue.add(ch); } public char popCharacter(){ return stack.pop(); } public char dequeueCharacter(){ return queue.remove(); } Problem solution in c++ programming. #include <iostream> #include <stack> #include <queue> using namespace std; class Solution { //Write your code here std::stack<char> mystack; std::queue<char> myqueue; public: void pushCharacter(char ch){ mystack.push(ch); } void enqueueCharacter(char ch){ myqueue.push(ch); } char popCharacter(){ char top = mystack.top(); mystack.pop(); return top; } char dequeueCharacter(){ char front = myqueue.front(); myqueue.pop(); return front; } }; Problem solution in Javascript programming. function Solution(){ this.stack = []; this.queue = []; } Solution.prototype.pushCharacter = function pushCharacter (char) { this.stack.push(char); }; Solution.prototype.enqueueCharacter = function enqueueCharacter (char) { this.queue.push(char); }; Solution.prototype.popCharacter = function popCharacter () { return this.stack.pop(); }; Solution.prototype.dequeueCharacter = function dequeueCharacter () { return this.queue.shift(); }; 30 days of code coding problems