3143. Longest Unequal Adjacent Groups Subsequence I
My accepted Python solution to LeetCode problem 3143, Longest Unequal Adjacent Groups Subsequence I, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2026-01-02.
class Solution:
def getLongestSubsequence(self, words: List[str], groups: List[int]) -> List[str]:
result = [words[0]]
prev_group = groups[0]
for i in range(1, len(words)):
if groups[i] != prev_group:
result.append(words[i])
prev_group = groups[i]
return result