Algorithm Training Camp Day 9: Implement Queue with Stacks, Stack with Queues, Valid Parentheses, Remove Adjacent Duplicates

232. Implement Queue using Stacks Problem: Implement a first-in-first-out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, pop, peek, empty): Implement the MyQueue class: void push(int x): Push element x to the back of the queue. int pop(): Removes the element from the front of ...

Posted on Sun, 27 Sep 2026 16:26:59 +0000 by Atomiku

Stack-Based Solutions for Valid Parentheses, Duplicate Removal, and Reverse Polish Notation

Valid Parentheses The solution utilizes a stack data structure to validate parentheses. When encountering an opening bracket, it is pushed onto the stack. For closing brackets, the algorithm checks whether the top of the stack matches the corresponding opening bracket. If not, the input is invalid. After processing all characters, a valid expre ...

Posted on Fri, 12 Jun 2026 18:08:11 +0000 by sandrob57

Validating Balanced Parentheses in Strings

Given a string s containing only the characters '(', ')', '{', '}', '[', and ']', determine if the string is valid. A valid string satisfies: Every opening bracket must be closed by a matcihng bracket of the same type. Brackets must close in the correct order. Each closing bracket croresponds to an opening bracket of the same type. Example 1: ...

Posted on Wed, 13 May 2026 17:47:57 +0000 by joaca