Skip to content

Commit

Permalink
[Algorithm] Counting sort 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jiriboy committed Jul 7, 2022
1 parent 47f9200 commit 8d905bd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Algorithm/Sort_Counting.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ for (int i = 0; i < arr.length; i++) {
counting[arr[i]]++;
}
// 과정 3 - counting 배열을 누적합으로 만들어주기.
for (int i = 1; i < arr.length; i++) {
for (int i = 1; i < counting.length; i++) {
counting[i] += counting[i - 1];
}
// 과정 4 - 뒤에서부터 배열을 돌면서, 해당하는 값의 인덱스에 값을 넣어주기.
for (int i = arr.length - 1; i >= 0; i--) {
sorted_arr[counting[arr[i]]] = arr[i];
sorted_arr[counting[arr[i]] - 1] = arr[i];
counting[arr[i]]--;
}
```
Expand Down

0 comments on commit 8d905bd

Please sign in to comment.