代码重构 【Github Actions】

This commit is contained in:
github-actions[bot]
2021-07-23 15:44:19 +00:00
parent c79cac3d9c
commit f671c90754
94 changed files with 1609 additions and 2111 deletions

View File

@@ -1,14 +1,14 @@
#### [leetcode 493 翻转对](https://leetcode-cn.com/problems/reverse-pairs/)
> 如果阅读时发现错误或者动画不可以显示的问题可以添加我微信好友 **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
> 如果阅读时发现错误或者动画不可以显示的问题可以添加我微信好友 **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
>
> 感谢支持该仓库会一直维护希望对各位有一丢丢帮助
>
> 另外希望手机阅读的同学可以来我的 <u>[**公众号袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
> 另外希望手机阅读的同学可以来我的 <u>[**公众号袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
**题目描述**
给定一个数组 nums 如果 i < j nums[i] > 2*nums[j] 我们就将 (i, j) 称作一个重要翻转对
给定一个数组 nums 如果 i < j nums[i] > 2\*nums[j] 我们就将 (i, j) 称作一个重要翻转对
你需要返回给定数组中的重要翻转对的数量
@@ -30,11 +30,11 @@
![翻转对](https://cdn.jsdelivr.net/gh/tan45du/test1@master/20210122/微信截图_20210214121010.50g9z0xgda80.png)
此时我们发现 6 > 2 * 2所以此时是符合情况的因为小数组是单调递增的所以 6 后面的元素都符合条件所以我们 count += mid - temp1 + 1则我们需要移动紫色指针判断后面是否还存在符合条件的情况
此时我们发现 6 > 2 \* 2所以此时是符合情况的因为小数组是单调递增的所以 6 后面的元素都符合条件所以我们 count += mid - temp1 + 1则我们需要移动紫色指针判断后面是否还存在符合条件的情况
![翻转对](https://cdn.jsdelivr.net/gh/tan45du/test1@master/20210122/微信截图_20210214121711.77crljdzra00.png)
我们此时发现 6 = 3 * 2不符合情况因为小数组都是完全有序的所以我们可以移动红色指针看下后面的数有没有符合条件的情况这样我们就可以得到翻转对的数目啦下面我们直接看动图加深下印象吧
我们此时发现 6 = 3 \* 2不符合情况因为小数组都是完全有序的所以我们可以移动红色指针看下后面的数有没有符合条件的情况这样我们就可以得到翻转对的数目啦下面我们直接看动图加深下印象吧
![](https://img-blog.csdnimg.cn/20210317192545806.gif#pic_center)
@@ -45,7 +45,7 @@ Java Code:
```java
class Solution {
private int count;
public int reversePairs(int[] nums) {
count = 0;
merge(nums, 0, nums.length - 1);
@@ -128,7 +128,7 @@ class Solution:
temp2 += 1
else:
temp1 += 1
# 记得归位我们还要继续使用
temp1 = left
temp2 = mid + 1
@@ -145,8 +145,7 @@ class Solution:
# 照旧
if temp1 <= mid:
temparr[index: index + mid - temp1 + 1] = nums[temp1: temp1 + mid - temp1 + 1]
if temp2 <= right:
if temp2 <= right:
temparr[index: index + right - temp2 + 1] = nums[temp2: temp2 + right - temp2 + 1]
nums[left: left + right- left + 1] = temparr[0: right - left + 1]
```