Skip to content

Longest Increasing Subsequence#18

Open
Exzrgs wants to merge 3 commits intomainfrom
arai60-longest-increasing-subsequence
Open

Longest Increasing Subsequence#18
Exzrgs wants to merge 3 commits intomainfrom
arai60-longest-increasing-subsequence

Conversation

class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
MAX_NUM = 10 ** 4
MIN_NUM = -(10 ** 4)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

この括弧不要では。

あと、こういうマジックナンバーはあまり行儀がいい感じがしないですね。

入力の制約を守らない入力を入れると、理解できない振る舞いをするんですよね。
数年間使うコードならば、そういうことは間違いなく起きますよね。
それに対して、入力の制約を守らなかったのが悪いのだから、デバッグに一日潰しても潰したやつが悪い、というのは良い同僚ではないでしょう。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

たしかにそうですね~
となると、10 ** 18とかを入れるのがbetterでしょうか?

また、定義するときはINF = 10 ** 18とかってやっちゃってもよいんですかね...?
Pythonにはfloat('inf')がありますが、速度が遅いのであまり使いたくないなあという気持ちです。

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.

2 participants