摘要:
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
随笔档案-2014年08月
求逆序对(inversion)的个数
2014-08-07 22:50 by valerlina, 3610 阅读, 收藏, 编辑
摘要:
2-4 逆序对 设A[1...n]是一个包含n个不同数的数组,如果在iA[j],则(i,j)就称为A中的一个逆序对(inversion)。 a)列出数组的5个逆序对 b)如果数组的元素取自集合{1,2,...,n}, 那么, 怎样的数组含有最多的逆序对?它包含多少个逆序对? c)插入排... 阅读全文