-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add ruby code block - merge sort #1260
feat: add ruby code block - merge sort #1260
Conversation
Hi @juminhong, please complete the check list. |
### 合并左子数组和右子数组 ### | ||
def merge(nums, left, mid, right) | ||
# 左子数组区间为 [left, mid], 右子数组区间为 [mid+1, right] | ||
# 创建一个临时数组tmp,用于存放合并后的结果 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the comment in another PR.
(By the way, submitting your work in only one PR is fine.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### 归并排序 ### | ||
def merge_sort(nums, left, right) | ||
# 终止条件 | ||
# 当子数组长度为1时终止递归 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j += 1 | ||
k += 1 | ||
end | ||
# 将临时数组tmp中的元素复制回原数组nums的对应区间 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @junminhong, I just have one small comment, the rest LGTM
Co-authored-by: khoaxuantu <68913255+khoaxuantu@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @junminhong, could you help me change the code as the following:
Co-authored-by: khoaxuantu <68913255+khoaxuantu@users.noreply.github.com>
Co-authored-by: khoaxuantu <68913255+khoaxuantu@users.noreply.github.com>
Co-authored-by: khoaxuantu <68913255+khoaxuantu@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
If this pull request (PR) pertains to Chinese-to-English translation, please confirm that you have read the contribution guidelines and complete the checklist below:
If this pull request (PR) is associated with coding or code transpilation, please attach the relevant console outputs to the PR and complete the following checklist:
result screenshot