Skip to content

Conversation

@Fuminiton
Copy link
Owner

- numsをはじめから見ていって、各長さのLISにおける末尾の最小値を保持するやり方もあった
- 発想も素直な気がするのでこれは思いついても良さそうだった
- ついでに`bisect_left`の実装をみたが、変数名が雑すぎるなあ
- https://github.com/python/cpython/blob/3.13/Lib/bisect.py#L74
Copy link

Choose a reason for hiding this comment

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

docstringをきちんと書いているからOKなんですかね。

def lengthOfLIS(self, nums: List[int]) -> int:
length_lis = [1] * len(nums)
for index in range(len(nums)):
for former_index in range(index):
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.

レビューありがとうございます。

見返してみると、
階層が深くなっているので関数化するのもありな気がしてきました。

Comment on lines +67 to +70
if insertion_position == len(tails):
tails.append(num)
else:
tails[insertion_position] = num
Copy link

Choose a reason for hiding this comment

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

私は、唐突にこれを逆にしたほうが素直かなと思いましたが

if insertion_position < len(tails):
    tails[insertion_position] = num
else:
    tails.append(num)

趣味の範囲です。

Copy link
Owner Author

Choose a reason for hiding this comment

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

レビューありがとうございます。
確かに「収まっている場合->収まっていない場合」となっていた方が自然ですね。

length_lis = [1] * len(nums)
for index in range(len(nums)):
for former_index in range(index):
if nums[index] > nums[former_index]:

Choose a reason for hiding this comment

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

ネスト深めなので、早期continueしたい気もします。

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.

5 participants