Skip to content

26.Remove Duplicates From Sorted Array#10

Open
rm3as wants to merge 5 commits intomainfrom
leetcode_easy
Open

26.Remove Duplicates From Sorted Array#10
rm3as wants to merge 5 commits intomainfrom
leetcode_easy

Conversation

@rm3as
Copy link
Copy Markdown
Owner

@rm3as rm3as commented Apr 21, 2024

Copy link
Copy Markdown

@nodchip nodchip left a comment

Choose a reason for hiding this comment

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

別の問題の回答ソースコードが混ざっているようです。

26.Remove Duplicates From Sorted Array の回答ソースコードのほうには、大きな違和感はありませんでした。

i += 1
nums[i] = nums[j]

return i+1 No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+ の両脇にそれぞれ 1 つずつスペースを空けるとよいと思います。詳しくは PEP8 をご覧ください。
https://peps.python.org/pep-0008/#other-recommendations

i = 1
for j in range(1, len(nums)):
if nums[i] == prev_num:
nums.pop(i)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

pop はその瞬間に後ろを全部ずらしますので、時間がかかりますね。

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