首页 > 其他 > 详细

[LeetCode] Reverse Pairs 翻转对

时间:2017-04-02 00:50:24      阅读:477      评论:0      收藏:0      [点我收藏+]

 

Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j].

You need to return the number of important reverse pairs in the given array.

Example1:

Input: [1,3,2,3,1]
Output: 2

 

Example2:

Input: [2,4,3,5,1]
Output: 3

 

Note:

  1. The length of the given array will not exceed 50,000.
  2. All the numbers in the input array are in the range of 32-bit integer.

 

s

 

[LeetCode] Reverse Pairs 翻转对

原文:http://www.cnblogs.com/grandyang/p/6657956.html

(1)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!