Skip to content

Commit

Permalink
question: maxGap
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelriosoliveira committed Mar 11, 2024
1 parent 09d36b8 commit 4519237
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/2024/343-maxGap/maxGap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ Example:
*/

export function maxGap(arr: number[]): number {
if (arr.length < 2) {
return 0;
}

return Math.max(
0, // minimum value (if less than 2 elements, the following computation gives '-Infinity')
...arr
.toSorted((a, b) => a - b)

Check failure on line 15 in src/2024/343-maxGap/maxGap.ts

View workflow job for this annotation

GitHub Actions / build

src/2024/343-maxGap/maxGap.test.ts > #maxGap > returns 3 for the array [3, 6, 9, 1, 2]

TypeError: arr.toSorted is not a function ❯ Module.maxGap src/2024/343-maxGap/maxGap.ts:15:5 ❯ src/2024/343-maxGap/maxGap.test.ts:5:10

Check failure on line 15 in src/2024/343-maxGap/maxGap.ts

View workflow job for this annotation

GitHub Actions / build

src/2024/343-maxGap/maxGap.test.ts > #maxGap > returns 0 for an empty array

TypeError: arr.toSorted is not a function ❯ Module.maxGap src/2024/343-maxGap/maxGap.ts:15:5 ❯ src/2024/343-maxGap/maxGap.test.ts:9:10

Check failure on line 15 in src/2024/343-maxGap/maxGap.ts

View workflow job for this annotation

GitHub Actions / build

src/2024/343-maxGap/maxGap.test.ts > #maxGap > returns 0 for an array with one element

TypeError: arr.toSorted is not a function ❯ Module.maxGap src/2024/343-maxGap/maxGap.ts:15:5 ❯ src/2024/343-maxGap/maxGap.test.ts:13:10

Check failure on line 15 in src/2024/343-maxGap/maxGap.ts

View workflow job for this annotation

GitHub Actions / build

src/2024/343-maxGap/maxGap.test.ts > #maxGap > returns the difference between two elements for an array with exactly two elements

TypeError: arr.toSorted is not a function ❯ Module.maxGap src/2024/343-maxGap/maxGap.ts:15:5 ❯ src/2024/343-maxGap/maxGap.test.ts:17:10
.map((number, i, array) => array[i + 1] - number)
Expand Down

0 comments on commit 4519237

Please sign in to comment.