To the Top
File:  root - text - article - 2019 - 12 - minimum-removals-for-valid-parenthesis.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 210 Views, 16834 Search Bots | 74 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Uber:

You are given a string of parenthesis. Return the minimum number of parenthesis that would need to be removed in order to make the string valid. "Valid" means that each open parenthesis has a matching closed parenthesis.

Example:

"()())()"

The following input should return 1.

")("

Here's a start:


def count_invalid_parenthesis(string):
# Fill this in.

print count_invalid_parenthesis("()())()")
# 1
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 210 Views, 16834 Search Bots | 74 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Question: Longest Sequence with Two Unique Numbers
  2. [Daily Problem] Longest Palindromic Substring
  3. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  4. CVE-2015-8874 - cPanel EasyApache Vulnerabilities
  5. A trick for getting good at coding interviews FASTER
  6. Algorithm Interview: Level Order Traversal of Binary Tree
  7. Algorithm Interview: Maximum Path Sum in Binary Tree
  8. Consecutive Ones
  9. Daily Interview Problem: Trapping Rainwater
  10. Daily Interview Problem: Spiral Traversal of Grid

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">