尝试理解问题的以下算法的运行时间;Remove the minimum number of invalid parentheses in order to make the input string validReturn all possible results
这是一个简单的BFS解决方案,它通过删除"(“或")”来生成所有可能的字符串。考虑到这一点-我很难弄清楚如何最终确定这个算法的运行时间。如何推广此算法并分析其复杂性?
如果您转到leetcode.com/problems/find-the-duplicate-number/solution/ (问题287),会给出以下解决方案: for num in nums: return num该解决方案的时间复杂度为这不是比O(N)时间长吗?
具体地说,如果您尝试在集合中查找98