在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。
链接:https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof
示例 1:
输入: [7,5,6,4]
输出: 5
解题思路
在归并数组时,加上统计逆序对的逻辑。
当 $rightArray$ 中的数据小于 $leftArray$ 时,可与 $leftArray$ 中的数据构成逆序对,计数器更新

|
|
树叶的一生,只是为了归根吗?
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia-plus根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true