You are using an outdated browser. Please update your browser for a better user experience.

Fix String

stack

Given a string, s, containing only '(' , ')' and lowercase English characters.

Your task is to fix the string. A string is fixed by removing the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid.

FIXED STRING MEANS:

  1. It is the...

isPalindrome (Stack/Queue implementation)

stack

Write the function isPalindrome that takes a string as input and outputs whether the string is a palindrome or not. Implement this function using a stack or a queue (although if you cannot, you can do it using for/while loops). Examples of palindromes are:

racecar
tacocat
borrowedorrob

Yo...

Minimum Add to Make Parentheses Valid

stack

Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid.

Formally, a parentheses string is valid if and only if:

  • It is the empty string, or
  • It can be written as AB (A conc...

Reverse Array using Stacks or Queues

stack

Hello! Reversing an array is pretty simple right? Make a for loop, add some stuff to a new array and you're done! But what if I told you there were an easier way?!?! Issa Stack or Queue So yeah, I want you to reverse an array using only a Stack or a Queue, you will be given a populated array of l...

Teemo Attacks!

stack

In League of Legends there is a character named Teemo who can poison his enemies. Given Teemo's attacking ascending time series towards his opponent and the poisoning time duration per Teemo's attacking, you need to output the total time that his opponent is in poisoned condition.

You may assum...

Valid Parentheses

stack

Given a string containing just the characters '(', ')', '{', '}', '[', ']', determine if the input string is valid.

An input string is valid if:

  • Open brackets must be closed by the same type of brackets.
  • Open brackets must be closed in the correct order.

Input: "()" Output: true

Inp...