All Questions
Tagged with stack programming-challenge
17 questions
3
votes
1
answer
575
views
Finding the minimum element of a stack of numbers
As part of an online programming challenge, I wrote a program that implements a stack of integers, supporting adding and removing elements, finding the last inserted element, and the minimum element. ...
4
votes
1
answer
975
views
Codility Fish (queue) programming challenge
Today I have attempted a Codility exercise "Fish" (https://app.codility.com/programmers/lessons/7-stacks_and_queues/fish/), and I have to say I found it to be:
1) Not necessarily "easy" as implied by ...
1
vote
1
answer
3k
views
Codility's stonewall 100% solution - different paths such as if,else if,etc, do the same thing
Here is the task description for the codility's stonewall problem. I would like to get a feedback on my code, and I specify at the bottom what the title states. (I had to make the figure by hand, ...
11
votes
3
answers
5k
views
HackerRank Implement Queue using two stacks Solution
Challenge
Problem Statement - Implement a Queue using two Stacks
I implemented dequeue() in \$O(1)\$ at the cost of enqueue() ...
3
votes
3
answers
1k
views
JavaScript Sort Stack Coding Challenge
A coding challenge to write a function sortStack that receives a stack of integers into ascending order (with largest integers on top) and returns another stack ...
5
votes
2
answers
941
views
Create a min stack
The task
is taken from leetcode
Design a stack that supports push, pop, top, and retrieving the
minimum element in constant time.
push(x) -- Push element x onto stack.
pop() -- Removes ...
25
votes
3
answers
9k
views
Leetcode: Valid parentheses
Leetcode: Valid parentheses
Given a string containing just the characters (, ), {, ...
6
votes
1
answer
1k
views
Leetcode number of atoms solution using stack
LeetCode 726. Number of Atoms
Given a chemical formula (given as a string), return the count of each
atom.
An atomic element always starts with an uppercase character, then zero
or more ...
5
votes
5
answers
2k
views
LeetCode parentheses matching
I came across this question from LeetCode OJ where I am given a string containing parentheses and I need to find out if the string contains valid matching parentheses or not.
Given a string ...
6
votes
2
answers
5k
views
Hackerrank CTCI "Stacks: Balanced Brackets" Javascript Solution
Here is the original problem, and below is my solution. I wonder what can be improved? Or is there a fundamentally better algorithm out there? Thank you! My intuition is telling me that it can be more ...
2
votes
1
answer
3k
views
Binary tree inorder traversal (iterative solution)
Problem statement
Given a binary tree, traversal the binary tree using inorder traversal, so the left child is visited first, and then node and then right child. Write an iterative solution as a ...
4
votes
3
answers
7k
views
C++ implementation of Hackerrank's "Maximum Element in a Stack"
I just attempted the Maximum Element Challenge on Hackerrank. This question has been posted before in swift Swift Hackerrank Maximum Element in a Stack but it has attracted low views/no answers. ...
3
votes
1
answer
608
views
Stack which finds the minimum element
Write a program to implement stack which implements min a method
which gives the minimum element below the top element in the stack.
...
5
votes
2
answers
5k
views
Poisonous Plants
I have solved the following problem. My code works but Hackerrank says that I can do faster:
There are plants in a garden. Each of these plants has been added
with some amount of pesticide. After ...
3
votes
1
answer
886
views
Check correctness of brackets in file with stack + error detection
Task:
My implementation:
...