Blogs Hub

by AskGif | Oct 18, 2020 | Category :coding

Maximum Nesting Depth of the Parentheses - Stack - Easy - LeetCode

Maximum Nesting Depth of the Parentheses - Stack - Easy - LeetCode

A string is a valid parentheses string (denoted VPS) if it meets one of the following: It is an empty string "", or a single character not equal to "(" or ")",<br />It can be written as AB (A concatenated with B), where A and B are VPS's, or<br />It can be written as (A), where A is a VPS.

read more...

by AskGif | Oct 03, 2020 | Category :coding

Crawler Log Folder - Stacks - Easy - LeetCode

Crawler Log Folder - Stacks - Easy - LeetCode

The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).<br />"./" : Remain in the sam

read more...

by AskGif | Oct 03, 2020 | Category :coding

Build an Array With Stack Operations - Stacks - Easy - LeetCode

Build an Array With Stack Operations - Stacks - Easy - LeetCode

Given an array target and an integer n. In each iteration, you will read a number from &nbsp;list = {1,2,3..., n}. Build the target array using the following operations: Push: Read a new element from the beginning list, and push it in the array.<br />Pop: delete the last element of

read more...

by AskGif | Oct 03, 2020 | Category :coding

Remove All Adjacent Duplicates In String - Stacks - Easy - LeetCode

Remove All Adjacent Duplicates In String - Stacks - Easy - LeetCode

Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. We repeatedly make duplicate removals on S until we no longer can. Return the final string after all such duplicate removals have been made. &nbsp;It is

read more...

by AskGif | Oct 03, 2020 | Category :coding

Remove Outermost Parentheses - Stacks - Easy - LeetCode

Remove Outermost Parentheses - Stacks - Easy - LeetCode

A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. &nbsp;For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings. A valid parentheses string S is primitive i

read more...

by AskGif | Oct 03, 2020 | Category :coding

Baseball Game - Stacks - Easy - LeetCode

Baseball Game - Stacks - Easy - LeetCode

You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round's score): Directly represents the number of points you get in this round.<br />"+" (one round's score): Represents that the points you get in this

read more...

by AskGif | Oct 03, 2020 | Category :coding

Next Greater Element I - Stacks - Easy - LeetCode

Next Greater Element I - Stacks - Easy - LeetCode

You are given two arrays (without duplicates) nums1 and nums2 where nums1&rsquo;s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. The Next Greater Number of a number x in nums1 is the first greater number to its rig

read more...

by AskGif | Oct 03, 2020 | Category :coding

Implement Queue using Stacks - Stack - Easy - LeetCode

Implement Queue using Stacks - Stack - Easy - LeetCode

Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of the queue.<br />pop() -- Removes the element from in front of the queue.<br />peek() -- Get the front element.<br />empty() -- Return whether the queue is empty.<br />Notes: You must

read more...

by AskGif | Oct 03, 2020 | Category :coding

Implement Stack using Queues - Stack - Easy - LeetCode

Implement Stack using Queues - Stack - Easy - LeetCode

Implement the following operations of a stack using queues. push(x) -- Push element x onto stack.<br />pop() -- Removes the element on top of the stack.<br />top() -- Get the top element.<br />empty() -- Return whether the stack is empty.<br />Example: MyStack stack = new MyStack();

read more...

by AskGif | Aug 08, 2018 | Category :coding

How can we get Minimum of Stack in a Constant Time O(1).

How can we get Minimum of Stack in a Constant Time O(1).

It is required to create a method getMinimum() which will give us the minimum in the current stack in O(1) time complexity. we will be using another stack for this to store the minimum at any particular point in time. We will take an auxiliary stack that maintains the minimum of all value

read more...

by AskGif | Aug 08, 2018 | Category :coding

What is a Stack?

What is a Stack?

A stack is a simple data structure used for storing data (similar to Linked Lists). In stack the order in which the data arrives is important. The pile of plates of a cafeteria is a good example of a stack. The plates are added to the stack as they are cleaned. They are placed on the top. When a

read more...

by AskGif | Aug 07, 2018 | Category :coding

Find the Merging Point of Two Linked Lists.

Find the Merging Point of Two Linked Lists.

Given pointers to the head nodes of linked lists that merge together at some point, find the Node where the two lists merge. It is guaranteed that the two head Nodes will be different, and neither will be NULL. We need to find the merging point of two linked lists. &nbsp;

read more...