Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
优点:
在每次迭代中,我们会按顺序填充当前边界,然后适当地更新这些边界。具体步骤如下:
从 left 到 right 填充 top 行,然后 top 加一。
从 top 到 bottom 填充 right 列,然后 right 减一。
如果 top 小于等于 bottom,则从 right 到 left 填充 bottom 行,然后 bottom 减一。
如果 left 小于等于 right,则从 bottom 到 top 填充 left 列,然后 left 加一。
这个过程将重复进行,直到填充所有元素。
*备注:只写了python新方法