0과 1로 구성된 배열 정렬0과 1로 이루어진 배열이 있다. 배열 자체를 오름차순으로 정렬하라. 입력: [1, 0, 1, 1, 1, 1, 1, 0, 0, 0], 출력: [0, 0, 0, 0, 1, 1, 1, 1, 1, 1] 입력: [1, 1], 출력: [1, 1] 방법1. sort() 사용12345arr = [1, 0, 1, 1, 1, 1, 1, 0, 0, 0]def get_increased_arr(arr): arr.sort() return arr sort() 메서드는 원본 배열을 오름차순으로 변경한다. 2. sorted() 사용12345arr = [1, 0, 1, 1, 1, 1, 1, 0, 0, 0]def get_increased_arr(arr): answer = sorted(arr) return answer 3. count() 사용123def get_increased_arr(arr): arr[:] = [0] * arr.count(0) + [1] * arr.count(1) return arr arr[:]을 사용하여 원본에 영향을 미치지 않고 복사할 수 있다. 4. 포인터 2개 사용12345678910111213def get_increased_arr(arr): left = 0 right = len(arr) - 1 while left < right: while arr[left] == 0: left += 1 while arr[right] == 1 and right >= 0: right -= 1 if left < right: arr[left], arr[right] = 0, 1 left, right = left + 1, right + 1 return arr