def solution(arr):
    answer = []
    cnt = 1
    prev = arr[0]
    for i in range(1, len(arr)):
        if arr[i] != prev:
            answer.append(prev)
        prev = arr[i]
    if arr[-1] == prev:
        answer.append(prev)
    return answer


arr = [4, 4, 4, 3, 3]
print(solution(arr))

e25fcf895afa3fd8167d7b6e78c54eff1858e117
<mask token>

def solution(arr):
    answer = []
    cnt = 1
    prev = arr[0]
    for i in range(1, len(arr)):
        if arr[i] != prev:
            answer.append(prev)
        prev = arr[i]
    if arr[-1] == prev:
        answer.append(prev)
    return answer


<mask token>

def solution(arr):
    answer = []
    cnt = 1
    prev = arr[0]
    for i in range(1, len(arr)):
        if arr[i] != prev:
            answer.append(prev)
        prev = arr[i]
    if arr[-1] == prev:
        answer.append(prev)
    return answer


<mask token>
print(solution(arr))

def solution(arr):
    answer = []
    cnt = 1
    prev = arr[0]
    for i in range(1, len(arr)):
        if arr[i] != prev:
            answer.append(prev)
        prev = arr[i]
    if arr[-1] == prev:
        answer.append(prev)
    return answer


arr = [4, 4, 4, 3, 3]
print(solution(arr))
