result to store the words of the longest subsequence.words array to result.last_group with the value of the first element in groups.groups array starting from the second element.groups, check if it is different from last_group.words to result and update last_group with the current group value.groups array.result list.