mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
tried to fix tests
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
* Reference article :- https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/
|
||||
*/
|
||||
|
||||
function kadaneAlgo (array) {
|
||||
export function kadaneAlgo (array) {
|
||||
let cummulativeSum = 0
|
||||
let maxSum = Number.NEGATIVE_INFINITY // maxSum has the least posible value
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@ -23,4 +23,3 @@ function kadaneAlgo (array) {
|
||||
return maxSum
|
||||
// This function returns largest sum contiguous sum in a array
|
||||
}
|
||||
export { kadaneAlgo }
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { kadaneAlgo } from '../KadaneAlgo'
|
||||
test('it is being checked that 15 is the answer to the corresponding array input', () => {
|
||||
expect(fc.kadaneAlgo([1, 2, 3, 4, 5])).toBe(15)
|
||||
expect(kadaneAlgo([1, 2, 3, 4, 5])).toBe(15)
|
||||
})
|
||||
|
||||
test('it is being checked that 5 is the answer to the corresponding array input', () => {
|
||||
expect(fc.kadaneAlgo([-1, -2, -3, -4, 5])).toBe(5)
|
||||
expect(kadaneAlgo([-1, -2, -3, -4, 5])).toBe(5)
|
||||
})
|
||||
|
Reference in New Issue
Block a user