Skip to content

Conversation

@Satorien
Copy link
Owner

return list(parentheses)
```

- と思ったが(())(())のような部分的に囲むやつが考慮できていないので失敗
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こういう風にしたいならば、はじめの括弧と対応するやつは必ずあるはずなので、
(X)Y
と分ければいいですね。

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どういう実装をイメージされているんでしょうか?
再帰だとできないのかなと思ったんですが、

```python
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
if n == 1:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n == 0 で [""] のほうがいいでしょう。

- 時間計算量:O(n^n)
- 各層の計算量が<2k C k
- 2k C k < k^k なので大体このくらい?
- 空間計算量:O(n^n)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これはちょっと大きすぎる見積もりです。

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ですね
下でもう少し正しい見積もりをしてみています

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants