I need to find the longest consecutive subsequence of a vector, and if there are more than 1 subsequence have the same longest length, I need the last one. My code is as below:
You could sort the lengths, which will put the last appearance of the longest length at the end. Then reverse the order and select the name of the first element to get the desired list element.