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 | 446 Views, 20089 Search Bots | 74 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 446 Views, 20089 Search Bots | 74 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 446 Views, 20089 Search Bots | 74 Words 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
Related Articles
- Daily Interview Problem: Look and Say Sequence
- [Daily Problem] Add two numbers as a linked list
- YES!!
- Daily Interview Problem: Running Median
- Fix Brackets
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Daily Interview Problem: Arithmetic Binary Tree
- Daily Interview Question: Find Cycles in a Graph
- Daily Interview Question: Create a Simple Calculator
©2006~2024 SteakOverCooked - 0.0074 Seconds(s) - 7311.079 KB/s - 35 Online Memory: 516.57 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !