mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
Fine tune
This commit is contained in:
@ -365,7 +365,7 @@ comments: true
|
||||
for (int i = nums.Length - 1; i > 0; i--)
|
||||
{
|
||||
bool flag = false; // 初始化标志位
|
||||
// 内循环:冒泡操作
|
||||
// 内循环:冒泡操作
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
if (nums[j] > nums[j + 1])
|
||||
|
||||
@ -151,7 +151,7 @@ comments: true
|
||||
// 内循环:将 base 插入到左边的正确位置
|
||||
while (j >= 0 && nums[j] > bas)
|
||||
{
|
||||
nums[j + 1] = nums[j]; // 1. 将 nums[j] 向右移动一位
|
||||
nums[j + 1] = nums[j]; // 1. 将 nums[j] 向右移动一位
|
||||
j--;
|
||||
}
|
||||
nums[j + 1] = bas; // 2. 将 base 赋值到正确位置
|
||||
|
||||
@ -352,7 +352,7 @@ comments: true
|
||||
void merge(int[] nums, int left, int mid, int right)
|
||||
{
|
||||
// 初始化辅助数组
|
||||
int[] tmp = nums[left..(right + 1)];//Array.CopyOfRange(nums, left, right + 1);
|
||||
int[] tmp = nums[left..(right + 1)];
|
||||
// 左子数组的起始索引和结束索引
|
||||
int leftStart = left - left, leftEnd = mid - left;
|
||||
// 右子数组的起始索引和结束索引
|
||||
|
||||
Reference in New Issue
Block a user