Stack

Longest Valid Parentheses

Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: s = “(()” Output: 2 Explanation: The longest valid parentheses substring is “()”. Example 2: Input: s = “)()())” Output: 4 Explanation: The longest valid parentheses substring is “()()”. Example 3: Input: s = “” …

Longest Valid Parentheses Read More »

Decode String

Hi geeks, in this article, we going to solve one interesting problem in leetcode, that is Decode string. It tests our analytical and problem solving skills. Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. …

Decode String Read More »