// Johnny Boldt // Mar 02, 2011 // johnny.boldt@gmail.com Once the answer to this problem is recongized, it is quite trivial. This problem is a Longest Decreasing Subsequence problem. Essentially, what is given is a list of numbers and we are looking for the largest subsequence that is decreasing. Dr. Howard Cheng has a function in his library that solves the Longest INCREASING Subsequence problem. So all I did was read in the data dynamically into a vector, and then copy it to a dynamically allocated array. When I copy it into the array, I also multiply each element by negative 1. My reasoning for this is that because Howard's function solves the Longest Increasing Problem, if I invert the numbers it instead solves the Longest Decreasing Problem for me. Before a < b, now b < a. Another method of doing this is reversing the order of the array. It should be noted, this "hack" only works because the numbers are positive. If the numbers were signed, it is possible that some test data could break the program. For example: Using chars, the number -128 * -1 = -128 since the data range for chars is -128 to 127. For every integer set, there will always be one more negative number than positive, so when using this hack one must be careful. Sometimes I use it to sort arrays backwards instead of writing my own sorting function.