Stacks and Queues

Categories: Code Problem / Data Structures and Algorithms / Recursion (32) Code Problem / Data Structures and Algorithms / Binary Search (30) Code Problem / Data Structures and Algorithms / Linked Lists (26) Code Problem / Data Structures and Algorithms / Backtracking (26) Code Problem / Data Structures and Algorithms / Stacks and Queues (25) Code Problem / Data Structures and Algorithms / Hashing (24) Databases / SQL / Backup and Recovery (19) Code Problem / Data Structures and Algorithms / Arrays and Strings (19) Databases / SQL / Database Normalization (18) Code Problem / Data Structures and Algorithms / Time Complexity (17) Databases / SQL / Locking (16) Databases / SQL / Replication (15) Databases / SQL / SQL Queries (13) Code Problem / Data Structures and Algorithms / Graphs (13) Databases / SQL / Database Security (13)  More...

Recent solutions:

Check these solutions from our community:
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given a stack of integers, the function returns the sum of the elements in the stack.
About this solution: The candidate's solution is correct and solves the problem. The approach is straightforward and easy to understand. The time complexity of the solution is O(n) and the space complexity is O(1).
Dec 11
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This function takes in a string consisting only of parentheses and outputs whether or not the string is balanced. A string is balanced if every open parenthesis has a corresponding close parenthesis and there are no unmatched parentheses.
About this solution: The candidate's solution does not demonstrate a level of completeness and does not solve the problem. The general approach is not clear.
Dec 10
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem asks the programmer to return the sum of all integers at even indices in a given list. For example, given the list [1, 2, 3, 4, 5], the output would be 6 (2 + 4).
About this solution: This solution is correct and efficient. The candidate has demonstrated a good understanding of how to use the slice operator to get every other element in a list.
Dec 09
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem asks you to reverse a string using a stack. An example input and output is provided.
About this solution: This is a good solution that uses a stack to reverse the string. The stack is a LIFO data structure, so the last character in the string will be the first character in the stack. The first character in the string will be the last character in the stack. The stack will be popped until it is empty, and the characters will be added to a new string. The new string will be the reversed string.
Dec 05
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
A stack is a data structure that supports push, pop, and min operations in constant time.
About this solution: The candidate's solution is complete and solves the problem. The candidate's approach is to use a second stack to keep track of the minimum value. When a new value is pushed onto the stack, it is also pushed onto the min stack if it is less than or equal to the current min value. When a value is popped off the stack, it is also popped off the min stack if it is equal to the current min value. This way, the min stack will always have the current min value at the top. This solution is optimal because it allows for constant time min operations.
Dec 04
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This technical problem deals with determining whether or not a given string consisting of only brackets is valid. A string is considered valid if the open brackets are closed by the same type of brackets in the correct order. An empty string is also considered valid.
About this solution: The candidate's solution is correct and uses a stack to keep track of the order of the brackets. The solution is also complete, with tests for all the different cases.
Dec 03
Code Problem / Data Structures and Algorithms DifficultyMedium Python
Given a list of integers, this code problem finds the largest integer in the list. For example, given the input [1, 2, 3, 4, 5], the output would be 5.
About this solution: This is a good solution that demonstrates a level of completeness and solves the problem. The approach is straightforward and easy to understand.
Dec 03
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given a string, reverse the order of the words. Do not use any built-in reverse functions.
About this solution: This solution is correct and demonstrates a level of completeness. The approach is straightforward and easy to understand. The time and space complexity of the solution is also optimal.
Dec 01