sudopower

LC: DC 2900: Longest Unequal Adjacent Groups Subsequence 1

lc_2900

Link to problem

Solution 1

func getLongestSubsequence(words []string, groups []int) []string {
    res := []string{words[0],}
    for i:=1;i<len(groups);i++{
        if groups[i]!=groups[i-1]{
            res = append(res,words[i])        
        }        
    }
    return res
}

Leave a Reply

Your email address will not be published. Required fields are marked *