Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bd6072

Browse files
Yavorskitrekhleb
Yavorski
authored andcommitted
Properly detect min and max element in array (trekhleb#224)
1 parent5d12638 commit6bd6072

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

‎src/algorithms/sorting/counting-sort/__test__/CountingSort.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ describe('CountingSort', () => {
2727
constsorter=newCountingSort({ visitingCallback});
2828

2929
// Detect biggest number in array in prior.
30-
constbiggestElement=notSortedArr.reduce((accumulator,element)=>{
31-
returnelement>accumulator ?element :accumulator;
32-
},0);
30+
constbiggestElement=Math.max(...notSortedArr);
3331

3432
// Detect smallest number in array in prior.
35-
constsmallestElement=notSortedArr.reduce((accumulator,element)=>{
36-
returnelement<accumulator ?element :accumulator;
37-
},0);
33+
constsmallestElement=Math.min(...notSortedArr);
3834

3935
constsortedArray=sorter.sort(notSortedArr,smallestElement,biggestElement);
4036

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp