Algorithms
Medium
2900
3143
Longest Unequal Adjacent Groups Subsequence I
longest-unequal-adjacent-groups-subsequence-i
"""
You are given an integer n, a 0-indexed string array words, and a 0-indexed binary array groups, both arrays having length n.

You need to select the longest subsequence from an array of indices [0, 1, ..., n - 1], such that for the subsequence denoted as [i0, i1, ..., ik - 1] having length k, groups[ij] != groups[ij + 1], for each j where 0 < j + 1 < k.

Return a string array containing the words corresponding to the indices (in order) in the selected subsequence. If there are multiple answers, return any of them.

A subsequence of an array is a new array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.

Note: strings in words may be unequal in length.

Example 1:

Input: n = 3, words = ["e","a","b"], groups = [0,0,1]
Output: ["e","b"]
Explanation: A subsequence that can be selected is [0,2] because groups[0] != groups[2].
So, a valid answer is [words[0],words[2]] = ["e","b"].
Another subsequence that can be selected is [1,2] because groups[1] != groups[2].
This results in [words[1],words[2]] = ["a","b"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 2.

Example 2:

Input: n = 4, words = ["a","b","c","d"], groups = [1,0,1,1]
Output: ["a","b","c"]
Explanation: A subsequence that can be selected is [0,1,2] because groups[0] != groups[1] and groups[1] != groups[2].
So, a valid answer is [words[0],words[1],words[2]] = ["a","b","c"].
Another subsequence that can be selected is [0,1,3] because groups[0] != groups[1] and groups[1] != groups[3].
This results in [words[0],words[1],words[3]] = ["a","b","d"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 3.


Constraints:

 * 1 <= n == words.length == groups.length <= 100
 * 1 <= words[i].length <= 10
 * 0 <= groups[i] < 2
 * words consists of distinct strings.
 * words[i] consists of lowercase English letters.
"""
class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:
        
You are given an integer n, a 0-indexed string array words, and a 0-indexed binary array groups, both arrays having length n.

You need to select the longest subsequence from an array of indices [0, 1, ..., n - 1], such that for the subsequence denoted as [i0, i1, ..., ik - 1] having length k, groups[ij] != groups[ij + 1], for each j where 0 < j + 1 < k.

Return a string array containing the words corresponding to the indices (in order) in the selected subsequence. If there are multiple answers, return any of them.

A subsequence of an array is a new array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.

Note: strings in words may be unequal in length.

Example 1:

Input: n = 3, words = ["e","a","b"], groups = [0,0,1]
Output: ["e","b"]
Explanation: A subsequence that can be selected is [0,2] because groups[0] != groups[2].
So, a valid answer is [words[0],words[2]] = ["e","b"].
Another subsequence that can be selected is [1,2] because groups[1] != groups[2].
This results in [words[1],words[2]] = ["a","b"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 2.

Example 2:

Input: n = 4, words = ["a","b","c","d"], groups = [1,0,1,1]
Output: ["a","b","c"]
Explanation: A subsequence that can be selected is [0,1,2] because groups[0] != groups[1] and groups[1] != groups[2].
So, a valid answer is [words[0],words[1],words[2]] = ["a","b","c"].
Another subsequence that can be selected is [0,1,3] because groups[0] != groups[1] and groups[1] != groups[3].
This results in [words[0],words[1],words[3]] = ["a","b","d"].
It is also a valid answer.
It can be shown that the length of the longest subsequence of indices that satisfies the condition is 3.


Constraints:

 * 1 <= n == words.length == groups.length <= 100
 * 1 <= words[i].length <= 10
 * 0 <= groups[i] < 2
 * words consists of distinct strings.
 * words[i] consists of lowercase English letters.


Please complete the code below to solve above prblem:
```python
class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:
        
```

my_solution = Solution()

test_input = { "n": 3, "words": ["e","a","b"], "groups": [0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["e","b"]

test_input = { "n": 4, "words": ["a","b","c","d"], "groups": [1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["a","b","c"]

test_input = { "n": 1, "words": ["c"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c"]

test_input = { "n": 1, "words": ["d"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d"]

test_input = { "n": 1, "words": ["e"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["e"]

test_input = { "n": 1, "words": ["fe"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["fe"]

test_input = { "n": 1, "words": ["frl"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["frl"]

test_input = { "n": 1, "words": ["ha"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ha"]

test_input = { "n": 1, "words": ["l"], "groups": [0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["l"]

test_input = { "n": 1, "words": ["n"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n"]

test_input = { "n": 1, "words": ["s"], "groups": [1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["s"]

test_input = { "n": 2, "words": ["d","g"], "groups": [0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d","g"]

test_input = { "n": 2, "words": ["lr","h"], "groups": [0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lr"]

test_input = { "n": 2, "words": ["wx","h"], "groups": [0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["wx","h"]

test_input = { "n": 2, "words": ["yw","n"], "groups": [0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["yw","n"]

test_input = { "n": 2, "words": ["z","n"], "groups": [0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z"]

test_input = { "n": 2, "words": ["zr","a"], "groups": [0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["zr"]

test_input = { "n": 3, "words": ["h","vv","kp"], "groups": [0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["h","vv","kp"]

test_input = { "n": 3, "words": ["m","v","y"], "groups": [0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["m","v","y"]

test_input = { "n": 3, "words": ["o","cfy","en"], "groups": [1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["o","cfy"]

test_input = { "n": 3, "words": ["tu","rv","bn"], "groups": [0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["tu"]

test_input = { "n": 4, "words": ["c","f","y","i"], "groups": [1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","f","y"]

test_input = { "n": 4, "words": ["c","w","h","s"], "groups": [0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","s"]

test_input = { "n": 4, "words": ["d","a","v","b"], "groups": [1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d","a","b"]

test_input = { "n": 4, "words": ["hh","svj","a","nr"], "groups": [1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["hh"]

test_input = { "n": 4, "words": ["im","j","xq","cjs"], "groups": [1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["im","j","cjs"]

test_input = { "n": 4, "words": ["m","dkg","r","h"], "groups": [1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["m","h"]

test_input = { "n": 4, "words": ["ow","qay","r","j"], "groups": [1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ow"]

test_input = { "n": 4, "words": ["r","k","pb","x"], "groups": [0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["r","pb","x"]

test_input = { "n": 4, "words": ["sq","do","bcj","nm"], "groups": [0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["sq","do","nm"]

test_input = { "n": 4, "words": ["sz","mq","j","u"], "groups": [0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["sz","j","u"]

test_input = { "n": 4, "words": ["x","nf","p","asn"], "groups": [1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["x"]

test_input = { "n": 4, "words": ["z","tkt","x","swy"], "groups": [1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z","tkt","x"]

test_input = { "n": 5, "words": ["ht","lw","ax","vi","fo"], "groups": [0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ht","ax","vi"]

test_input = { "n": 5, "words": ["mc","kh","x","q","z"], "groups": [0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["mc","x","z"]

test_input = { "n": 5, "words": ["n","fg","fy","tv","gv"], "groups": [1,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n"]

test_input = { "n": 5, "words": ["n","l","e","d","m"], "groups": [1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n","e","d"]

test_input = { "n": 5, "words": ["n","m","g","b","d"], "groups": [0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n","g","b"]

test_input = { "n": 5, "words": ["nz","zwt","hig","s","jze"], "groups": [1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["nz","s","jze"]

test_input = { "n": 5, "words": ["o","i","b","k","kz"], "groups": [0,0,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["o","b"]

test_input = { "n": 5, "words": ["r","o","k","d","f"], "groups": [0,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["r","d"]

test_input = { "n": 5, "words": ["sfh","exd","j","w","gc"], "groups": [1,0,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["sfh","exd","j"]

test_input = { "n": 5, "words": ["v","f","k","l","p"], "groups": [0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["v","k","l"]

test_input = { "n": 5, "words": ["vbd","ua","muo","mu","qi"], "groups": [0,0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["vbd","mu","qi"]

test_input = { "n": 5, "words": ["we","ch","tl","yx","utx"], "groups": [1,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["we","ch","yx"]

test_input = { "n": 5, "words": ["x","vlk","tds","dfn","kr"], "groups": [0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["x","tds","kr"]

test_input = { "n": 5, "words": ["y","j","u","r","f"], "groups": [0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","u","f"]

test_input = { "n": 5, "words": ["y","r","z","x","q"], "groups": [0,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","r","z","x"]

test_input = { "n": 5, "words": ["yc","fgq","gg","og","tca"], "groups": [0,1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["yc","fgq","tca"]

test_input = { "n": 5, "words": ["z","d","p","c","m"], "groups": [0,0,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z"]

test_input = { "n": 6, "words": ["c","i","to","kv","op","u"], "groups": [0,0,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","to","kv"]

test_input = { "n": 6, "words": ["d","h","e","k","j","r"], "groups": [0,1,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["d","h","k","j","r"]

test_input = { "n": 6, "words": ["l","f","v","b","w","k"], "groups": [1,0,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["l","f","v","w"]

test_input = { "n": 6, "words": ["lj","vf","pa","w","z","q"], "groups": [0,0,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lj","pa","w"]

test_input = { "n": 7, "words": ["cd","oki","ho","oi","m","yvy","i"], "groups": [1,1,0,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["cd","ho","oi"]

test_input = { "n": 7, "words": ["exb","c","oq","lq","xh","zmo","aug"], "groups": [1,1,0,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["exb","oq","lq","zmo"]

test_input = { "n": 7, "words": ["f","r","k","h","m","v","p"], "groups": [1,0,0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["f","r","m","v"]

test_input = { "n": 7, "words": ["fd","fc","jm","z","lg","kl","ux"], "groups": [0,1,0,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["fd","fc","jm","z","lg","kl","ux"]

test_input = { "n": 7, "words": ["ft","iw","m","v","gx","d","pm"], "groups": [1,1,1,0,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ft","v","gx"]

test_input = { "n": 7, "words": ["lma","i","rt","xar","bfx","np","x"], "groups": [1,1,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lma","np","x"]

test_input = { "n": 7, "words": ["nsv","r","o","qo","pb","xqv","clb"], "groups": [1,1,0,0,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["nsv","o"]

test_input = { "n": 7, "words": ["p","qdb","zcd","l","tv","ln","ogb"], "groups": [1,1,0,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["p","zcd","l","tv","ogb"]

test_input = { "n": 7, "words": ["z","cee","j","jqu","w","ljr","k"], "groups": [1,0,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["z","cee","j","w","k"]

test_input = { "n": 8, "words": ["h","p","q","t","j","a","c","n"], "groups": [0,1,1,1,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["h","p","j","c"]

test_input = { "n": 8, "words": ["r","v","c","t","d","a","x","o"], "groups": [1,1,0,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["r","c","t","a","o"]

test_input = { "n": 8, "words": ["u","l","a","y","j","s","h","q"], "groups": [0,0,0,0,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["u","s","h"]

test_input = { "n": 8, "words": ["x","mr","yyf","l","z","q","zvj","zqt"], "groups": [0,1,1,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["x","mr","z","q","zqt"]

test_input = { "n": 8, "words": ["y","x","i","xtm","ze","n","cma","dgk"], "groups": [0,1,0,0,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","x","i","ze","cma"]

test_input = { "n": 8, "words": ["yun","x","zpp","bpr","ii","ezg","dn","k"], "groups": [0,1,1,1,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["yun","x","ezg","dn","k"]

test_input = { "n": 9, "words": ["ckr","iz","top","of","sb","wv","hb","da","wd"], "groups": [1,1,0,1,1,0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ckr","top","of","wv","wd"]

test_input = { "n": 9, "words": ["g","h","u","n","w","o","f","p","m"], "groups": [1,0,0,1,1,0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["g","h","n","o","p","m"]

test_input = { "n": 9, "words": ["ilw","t","dyy","irz","oxy","k","rfj","hi","zxe"], "groups": [1,1,1,0,1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ilw","irz","oxy","rfj","hi"]

test_input = { "n": 9, "words": ["l","iuz","d","tfw","mu","a","rp","mrb","wnl"], "groups": [1,1,1,1,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["l","a","rp","wnl"]

test_input = { "n": 9, "words": ["mc","b","yr","cj","zk","wi","esm","yu","cw"], "groups": [0,0,1,1,0,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["mc","yr","zk","esm","cw"]

test_input = { "n": 9, "words": ["nw","hx","ygc","vjo","jmv","p","juv","b","y"], "groups": [0,1,0,0,1,0,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["nw","hx","ygc","jmv","p","b","y"]

test_input = { "n": 9, "words": ["osq","qiw","h","tc","xg","tvt","fqp","zq","b"], "groups": [0,0,1,0,1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["osq","h","tc","xg","fqp","zq"]

test_input = { "n": 9, "words": ["vr","lw","e","g","dz","kf","qe","h","p"], "groups": [1,0,0,1,1,0,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["vr","lw","g","kf"]

test_input = { "n": 10, "words": ["gy","nd","l","hr","i","qf","zz","nq","e","oa"], "groups": [0,1,0,0,1,0,1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["gy","nd","l","i","qf","zz","oa"]

test_input = { "n": 10, "words": ["j","r","h","t","z","b","a","s","v","q"], "groups": [1,0,1,1,1,1,0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["j","r","h","a","q"]

test_input = { "n": 10, "words": ["k","f","u","h","x","w","c","e","l","p"], "groups": [0,1,1,1,1,1,1,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["k","f","p"]

test_input = { "n": 10, "words": ["lj","huy","lg","h","o","b","ava","ay","r","us"], "groups": [1,1,1,1,0,0,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["lj","o","ava"]

test_input = { "n": 10, "words": ["m","d","xv","dp","nq","xi","e","g","n","qw"], "groups": [1,0,1,1,1,1,0,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["m","d","xv","e","g","n","qw"]

test_input = { "n": 10, "words": ["n","c","y","h","w","m","g","t","x","v"], "groups": [1,1,1,0,0,1,0,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["n","h","m","g","v"]

test_input = { "n": 10, "words": ["o","w","l","g","m","x","f","q","c","v"], "groups": [1,1,1,0,1,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["o","g","m","q","v"]

test_input = { "n": 10, "words": ["p","mw","m","xld","j","jv","n","so","pkd","rwt"], "groups": [0,0,1,0,1,1,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["p","m","xld","j","n","pkd"]

test_input = { "n": 10, "words": ["vyv","msl","d","bu","ubl","bgk","sz","njv","pf","s"], "groups": [1,0,1,1,0,0,1,0,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["vyv","msl","d","ubl","sz","njv","pf","s"]

test_input = { "n": 10, "words": ["y","mz","lt","ur","o","m","djh","tb","w","j"], "groups": [0,0,1,0,1,1,0,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","lt","ur","o","djh","tb","w"]

test_input = { "n": 10, "words": ["y","s","i","v","a","w","l","q","k","t"], "groups": [0,1,1,1,0,1,1,1,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["y","s","a","w","k"]

test_input = { "n": 11, "words": ["a","tea","ldt","ybm","zkw","r","d","dms","le","u","ze"], "groups": [1,1,0,0,0,1,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["a","ldt","r","u","ze"]

test_input = { "n": 11, "words": ["c","o","e","r","x","w","b","d","h","y","z"], "groups": [1,0,1,0,1,0,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["c","o","e","r","x","w","b","y","z"]

test_input = { "n": 11, "words": ["chu","a","qdx","fgd","qe","bqc","x","kbx","sv","ly","br"], "groups": [1,0,0,0,0,0,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["chu","a","x","kbx","sv","br"]

test_input = { "n": 11, "words": ["ec","jdf","b","wa","kjd","bb","ty","yi","ybw","ilj","cv"], "groups": [0,1,0,1,1,1,1,1,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ec","jdf","b","wa","ilj","cv"]

test_input = { "n": 11, "words": ["ew","isn","fl","mg","pdg","d","p","hh","e","y","whm"], "groups": [0,0,1,1,0,0,0,0,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ew","fl","pdg","y"]

test_input = { "n": 11, "words": ["h","o","d","y","r","c","p","b","g","j","k"], "groups": [1,1,0,1,1,0,1,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["h","d","y","c","p","g"]

test_input = { "n": 11, "words": ["ipr","l","zy","j","h","hdt","m","d","pd","nv","wy"], "groups": [1,1,1,1,0,1,0,1,1,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ipr","h","hdt","m","d"]

test_input = { "n": 11, "words": ["j","g","go","a","f","bg","o","l","ze","kq","w"], "groups": [0,0,1,0,1,0,0,0,1,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["j","go","a","f","bg","ze","kq","w"]

test_input = { "n": 11, "words": ["j","r","a","g","x","b","y","v","k","i","c"], "groups": [0,1,0,0,0,0,1,1,0,0,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["j","r","a","y","k"]

test_input = { "n": 11, "words": ["kgo","han","nlu","tv","us","pk","xw","cxc","eml","v","msz"], "groups": [1,0,0,1,0,0,1,0,1,1,0] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["kgo","han","tv","us","xw","cxc","eml","msz"]

test_input = { "n": 11, "words": ["kh","op","ij","te","hk","pmt","v","ne","en","b","zuj"], "groups": [0,0,1,1,1,0,1,1,0,1,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["kh","ij","pmt","v","en","b"]

test_input = { "n": 11, "words": ["ms","t","oz","x","pw","ik","d","gj","z","ps","i"], "groups": [1,1,0,1,0,0,1,1,0,0,1] }
assert my_solution.getWordsInLongestSubsequence(**test_input) == ["ms","oz","x","pw","d","z","i"]