文件: root - text - article - 2019 - 12 - minimum-removals-for-valid-parenthesis.txt.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 446 次阅读, 20044 次搜索 | 74 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 446 次阅读, 20044 次搜索 | 74 个单词
| 浏览 | 博客存档
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:
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 446 次阅读, 20044 次搜索 | 74 个单词 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
猜您喜欢...
- Daily Interview Problem: Find the k-th Largest Element in a List
- Algorithm Interview Question: H-Index
- Daily Interview Problem: Arithmetic Binary Tree
- Daily Interview Problem: Circle of Chained Words
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
- Daily Interview Problem: Maximum Profit From Stocks
- A trick for getting good at coding interviews FASTER
- Daily Interview Problem: Merge K Sorted Linked Lists
- Daily Interview Puzzle: Minimum Size Subarray Sum
- Algorithm Interview: No Adjacent Repeating Characters
©2006~2024 牛排过熟 - 0.00723 秒 - 2860.232 KB/s - 26 在线 内存: 494.3 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="索引, 跟踪">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。