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 | 465 Views, 21495 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 | 465 Views, 21495 Search Bots | 74 Words Subscribe to Feed Burner

Related Articles

  1. Algorithm Interview: Determine If Linked List is Palindrome
  2. ImageMagick Vulnerabilities -  CVE-2016–3714
  3. Algorithm Interview: Level Order Traversal of Binary Tree
  4. Spreadsheet Columns
  5. Daily Interview Problem: Trapping Rainwater
  6. Daily Interview Problem: Sort Colors
  7. Daily Interview Problem: Count Number of Unival Subtrees
  8. Daily Interview Problem: Largest Product of 3 Elements I
  9. Spectrum Master
  10. Algorithm Interview: String Compression

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">