-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
숫자가 모두 채워진 triangle 을 기반으로 1차원 배열에 옮길 때
triangle[i][j] 의 값이 0이 아닌지 체크 하지 않아 초기 선언한 result 배열의 사이즈보다 큰 index 값을 할당하려고 하여
out of bounds 오류가 발생합니다.
코드 위치 : https://github.com/gilbutITbook/080337/blob/main/3%EC%9E%A5/%EC%82%BC%EA%B0%81_%EB%8B%AC%ED%8C%BD%EC%9D%B4.java#L43
따라서 아래와 같이 if 문을 추가해야 할 것 같습니다.
if (triangle[i][j] != 0) { result[index++] = triangle[i][j]; }
Metadata
Metadata
Assignees
Labels
No labels