Skip to content
Programming101
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

Learn everything about programming

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.

Day 18 Queues and Stacks 30 days of code solution Hackerrank

Topics we are covering

Toggle
  • Problem solution in Python 2 programming. 
  • Problem solution in Python 3 programming.
    • Problem solution in java programming.
    • Problem solution in c++ programming.
    • Problem solution in Javascript programming.

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 solutions

Post navigation

Previous post
Next post
  • Automating Image Format Conversion with Python: A Complete Guide
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes