같은 숫자는 싫어 (Level 1)

정은경·2020년 8월 16일
0

1. 문제

2. 나의 풀이

def solution(arr):
    answer = []
    
    for a in arr:
        if not answer:
            answer.append(a)
        else:
            if answer[-1] != a:
                answer.append(a)
    
    # [실행] 버튼을 누르면 출력 값을 볼 수 있습니다.
    # print('Hello Python')
    return answer

3. 남의 풀이

def no_continuous(s):
    result = []
    for c in s:
        if (len(result) == 0) or (result[-1] != c):
            result.append(c)
    return result

4. 느낀 점

profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글