docs: fix typos (#1283)

* docs: fix typos

* fix
This commit is contained in:
Lioness100
2023-02-07 08:50:28 -08:00
committed by GitHub
parent 8cd86b1eda
commit 002b10a5aa
24 changed files with 47 additions and 47 deletions

View File

@ -1,6 +1,6 @@
/* Kadane's algorithm is one of the most efficient ways to
* calculate the maximum contiguous subarray sum for a given array.
* Below is the implementation of kadanes's algorithm along with
* Below is the implementation of Kadane's algorithm along with
* some sample test cases.
* There might be a special case in this problem if al the elements
* of the given array are negative. In such a case, the maximum negative
@ -10,14 +10,14 @@
*/
export function kadaneAlgo (array) {
let cummulativeSum = 0
let cumulativeSum = 0
let maxSum = Number.NEGATIVE_INFINITY // maxSum has the least possible value
for (let i = 0; i < array.length; i++) {
cummulativeSum = cummulativeSum + array[i]
if (maxSum < cummulativeSum) {
maxSum = cummulativeSum
} else if (cummulativeSum < 0) {
cummulativeSum = 0
cumulativeSum = cumulativeSum + array[i]
if (maxSum < cumulativeSum) {
maxSum = cumulativeSum
} else if (cumulativeSum < 0) {
cumulativeSum = 0
}
}
return maxSum

View File

@ -63,7 +63,7 @@ const uniquePaths2 = (obstacles) => {
grid[0][j] = 1
}
// Fill the rest of grid by dynamic programming
// using following reccurent formula:
// using following recurrent formula:
// K[i][j] = K[i - 1][j] + K[i][j - 1]
for (let i = 1; i < rows; i++) {
for (let j = 1; j < columns; j++) {