mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-12-19 06:58:15 +08:00
chore: update spelling mistakes (#1790)
* chore: update spelling mistakes * chore: add spellignore * chore: update sp mistakes
This commit is contained in:
2
.github/workflows/Ci.yml
vendored
2
.github/workflows/Ci.yml
vendored
@@ -36,4 +36,4 @@ jobs:
|
||||
with:
|
||||
# file types to ignore
|
||||
skip: "*.json,*.yml,DIRECTORY.md"
|
||||
ignore_words_list: "ba,esy,yse,falsy"
|
||||
ignore_words_list: "ba,esy,yse,falsy,abd"
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,5 +14,7 @@ yarn-error.log*
|
||||
|
||||
# intelliJ workspace folder
|
||||
.idea
|
||||
.vscode
|
||||
.trae
|
||||
|
||||
/coverage
|
||||
|
||||
@@ -52,7 +52,7 @@ function keyFinder(str) {
|
||||
return k // return the key number if founded
|
||||
}
|
||||
outStrElement = '' // reset the temp word
|
||||
} // end for ( let i=0; i < wordBank.length; i++)
|
||||
} // end for (let i=0; i < wordBank.length; i++)
|
||||
}
|
||||
}
|
||||
return 0 // return 0 if found nothing
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
* [UpperCaseConversion](Conversions/UpperCaseConversion.js)
|
||||
* **Data-Structures**
|
||||
* **Array**
|
||||
* [LocalMaximomPoint](Data-Structures/Array/LocalMaximomPoint.js)
|
||||
* [LocalMaximumPoint](Data-Structures/Array/LocalMaximumPoint.js)
|
||||
* [NumberOfLocalMaximumPoints](Data-Structures/Array/NumberOfLocalMaximumPoints.js)
|
||||
* [QuickSelect](Data-Structures/Array/QuickSelect.js)
|
||||
* [Reverse](Data-Structures/Array/Reverse.js)
|
||||
|
||||
@@ -44,6 +44,6 @@ const findMaxPointIndex = (
|
||||
}
|
||||
}
|
||||
|
||||
const LocalMaximomPoint = (A) => findMaxPointIndex(A, 0, A.length - 1, A.length)
|
||||
const LocalMaximumPoint = (A) => findMaxPointIndex(A, 0, A.length - 1, A.length)
|
||||
|
||||
export { LocalMaximomPoint }
|
||||
export { LocalMaximumPoint }
|
||||
@@ -1,29 +1,29 @@
|
||||
import { LocalMaximomPoint } from '../LocalMaximomPoint'
|
||||
import { LocalMaximumPoint } from '../LocalMaximumPoint'
|
||||
|
||||
describe('LocalMaximumPoint tests', () => {
|
||||
it('test boundary maximum points - last element', () => {
|
||||
const Array = [1, 2, 3, 4, 5, 6, 12]
|
||||
expect(LocalMaximomPoint(Array)).toEqual(6)
|
||||
expect(LocalMaximumPoint(Array)).toEqual(6)
|
||||
})
|
||||
|
||||
it('test boundary maximum points - first element', () => {
|
||||
const Array2 = [13, 6, 5, 4, 3, 2, 1]
|
||||
expect(LocalMaximomPoint(Array2)).toEqual(0)
|
||||
expect(LocalMaximumPoint(Array2)).toEqual(0)
|
||||
})
|
||||
|
||||
it('test boundary maximum points - should find first maximom point from the top', () => {
|
||||
it('test boundary maximum points - should find first maximum point from the top', () => {
|
||||
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
||||
const Array = [13, 2, 3, 4, 5, 6, 12]
|
||||
expect(LocalMaximomPoint(Array)).toEqual(6)
|
||||
expect(LocalMaximumPoint(Array)).toEqual(6)
|
||||
})
|
||||
|
||||
it('test inner points - second element', () => {
|
||||
const Array2 = [13, 16, 5, 4, 3, 2, 1]
|
||||
expect(LocalMaximomPoint(Array2)).toEqual(1)
|
||||
expect(LocalMaximumPoint(Array2)).toEqual(1)
|
||||
})
|
||||
|
||||
it('test inner points - element some where in the middle', () => {
|
||||
const Array2 = [13, 16, 5, 41, 3, 2, 1]
|
||||
expect(LocalMaximomPoint(Array2)).toEqual(3)
|
||||
expect(LocalMaximumPoint(Array2)).toEqual(3)
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NumberOfLocalMaximumPoints } from '../NumberOfLocalMaximumPoints'
|
||||
|
||||
describe('LocalMaximomPoint tests', () => {
|
||||
describe('LocalMaximumPoint tests', () => {
|
||||
it('test boundary maximum points - last element', () => {
|
||||
const Array = [1, 2, 3, 4, 5, 6, 12]
|
||||
expect(NumberOfLocalMaximumPoints(Array)).toEqual(1)
|
||||
|
||||
@@ -64,7 +64,7 @@ class SegmentTree {
|
||||
}
|
||||
}
|
||||
|
||||
// interval [L,R) with left index(L) included and right (R) excluded.
|
||||
// interval [L, R) with left index(L) included and right (R) excluded.
|
||||
query(left, right) {
|
||||
const { size, tree } = this
|
||||
// cause R is excluded, increase right for convenient
|
||||
|
||||
@@ -30,7 +30,7 @@ const uniquePaths = (m, n) => {
|
||||
for (let j = 1; j < m; j++) {
|
||||
// paths[j] in RHS represents the cell value stored above the current cell
|
||||
// paths[j-1] in RHS represents the cell value stored to the left of the current cell
|
||||
// paths [j] on the LHS represents the number of distinct pathways to the cell (i,j)
|
||||
// paths [j] on the LHS represents the number of distinct pathways to the cell (i, j)
|
||||
paths[j] = paths[j - 1] + paths[j]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function compare(a, b) {
|
||||
return 1
|
||||
}
|
||||
function orientation(a, b, c) {
|
||||
// Check orientation of Line(a,b) and Line(b,c)
|
||||
// Check orientation of Line(a, b) and Line(b, c)
|
||||
const alpha = (b.y - a.y) / (b.x - a.x)
|
||||
const beta = (c.y - b.y) / (c.x - b.x)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
function createGraph(V, E) {
|
||||
// V - Number of vertices in graph
|
||||
// E - Number of edges in graph (u,v,w)
|
||||
// E - Number of edges in graph (u, v, w)
|
||||
const adjList = [] // Adjacency list
|
||||
for (let i = 0; i < V; i++) {
|
||||
adjList.push([])
|
||||
|
||||
@@ -16,7 +16,7 @@ const abs = (num) => {
|
||||
throw new TypeError('Argument is NaN - Not a Number')
|
||||
}
|
||||
|
||||
return validNumber < 0 ? -validNumber : validNumber // if number is less than zero mean negative then it converted to positive. i.e -> n = -2 = -(-2) = 2
|
||||
return validNumber < 0 ? -validNumber : validNumber // if number is less than zero means negative, then it converted to positive. i.e., n = -2 = -(-2) = 2
|
||||
}
|
||||
|
||||
export { abs }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// To calculate x^n i.e. exponent(x, n) in O(log n) time in iterative way
|
||||
// To calculate x^n i.e., exponent(x, n) in O(log n) time in iterative way
|
||||
// n is an integer and n >= 0
|
||||
|
||||
// Explanation: https://en.wikipedia.org/wiki/Exponentiation_by_squaring
|
||||
|
||||
@@ -17,7 +17,7 @@ export const EulersTotient = (n) => {
|
||||
while (n % i === 0) {
|
||||
n = Math.floor(n / i)
|
||||
}
|
||||
// i is a prime diving n, multiply res by 1 - 1/i
|
||||
// i is a prime dividing n, multiply res by 1 - 1/i
|
||||
// res = res * (1 - 1/i) = res - (res / i)
|
||||
res = res - Math.floor(res / i)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const gcdOfTwoNumbers = (x, y) => {
|
||||
// let gcd of x and y is gcdXY
|
||||
// so it divides x and y completely
|
||||
// so gcdXY should also divide y%x (y = gcdXY*a and x = gcdXY*b and y%x = y - x*k so y%x = gcdXY(a - b*k))
|
||||
// and gcd(x,y) is equal to gcd(y%x , x)
|
||||
// and gcd(x,y) is equal to gcd(y%x, x)
|
||||
return x === 0 ? y : gcdOfTwoNumbers(y % x, x)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ const matrixCheck = (matrix) => {
|
||||
}
|
||||
}
|
||||
|
||||
// tests to see if the matrices have a like side, i.e. the row length on the first matrix matches the column length on the second matrix, or vice versa.
|
||||
// tests to see if the matrices have a like side, i.e., the row length on the first matrix matches the column length on the second matrix, or vice versa.
|
||||
const twoMatricesCheck = (first, second) => {
|
||||
const [firstRowLength, secondRowLength, firstColLength, secondColLength] = [
|
||||
first.length,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
class Polynomial {
|
||||
constructor(array) {
|
||||
this.coefficientArray = array // array of coefficients
|
||||
this.polynomial = '' // in terms of x e.g. (2x) + (1)
|
||||
this.polynomial = '' // in terms of x e.g., (2x) + (1)
|
||||
this.construct()
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,6 @@ describe('Testing powFaster function', () => {
|
||||
})
|
||||
|
||||
it('should return the result in O(lonN) complexity', () => {
|
||||
expect(powFaster(2, 64)).toBe(18446744073709552000) // execution time Math.log2(64) -> 6
|
||||
expect(powFaster(2, 64)).toBe(18446744073709552000) // execution time Math. log2(64) -> 6
|
||||
})
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ function UnionFind(n, key) {
|
||||
}
|
||||
let cnt, length
|
||||
// init Union Find with number of distinct groups. Each group will be referred to as index of the array of size 'size' starting at 0.
|
||||
// Provide an optional key function that maps these indices. I.e. for the groups starting with 1 provide function(a){return a-1;}. The default value is function(a){return a;}.
|
||||
// Provide an optional key function that maps these indices. I.e., for the groups starting with 1 provide function(a){return a-1;}. The default value is function(a){return a;}.
|
||||
key =
|
||||
key ||
|
||||
function (a) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* like "2A3*3a2", "2A3 3a2", and "2_A3*3#A2"
|
||||
*
|
||||
* But the catch is, we have to check only if the alphanumeric characters
|
||||
* are palindrome i.e remove spaces, symbols, punctuations etc
|
||||
* are palindrome i.e remove spaces, symbols, punctuation etc
|
||||
* and the case of the characters doesn't matter
|
||||
*/
|
||||
const alphaNumericPalindrome = (str) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Palindrome check is case sensitive; i.e. Aba is not a palindrome
|
||||
// Palindrome check is case sensitive; i.e., Aba is not a palindrome
|
||||
// input is a string
|
||||
const checkPalindrome = (str) => {
|
||||
// check that input is a string
|
||||
|
||||
Reference in New Issue
Block a user