//****************************************************************************************************
//
// 求一个数组的最长递减子序列 - C++ - by Chimomo
//
// 题目: 求一个数组的最长递减子序列,比方{8, 14, 6, 2, 8, 14, 3, 2, 7, 4, 7, 2, 8, 101, 23, 6, 1, 2, 1, 1}的最长递减子序列为{14。8,3。2,1}。
//
// Answer: Scan from left to right, maintain a decreasing sequence. For each number, binary search in the decreasing sequence to see whether it can be substituted.
//
//****************************************************************************************************
#include
#include
#include
using namespace std ;
int BinarySearch(int *A, int nTarget, int nLen);
// Find the longest decreasing sequence in array A of length nLen.
void FindLongestDecreasingSequence(int *A, int nLen)
{
int *index =