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

Commit de118c6

Browse files
Merge remote-tracking branch 'origin/fixing-string-folder-JSDOCS' into fix-jsdocs
2 parents 8f10dee + 575eead commit de118c6

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

‎String/BoyerMoore.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/*
2-
*
3-
*
4-
*Implementation of the Boyer-Moore String Search Algorithm.
5-
*The Boyer–Moore string search algorithm allows linear time in
6-
*search by skipping indices when searching inside a string for a pattern.
7-
*
8-
*
9-
*
10-
*
11-
**/
1+
/**
2+
* Implementation of the Boyer-Moore String Search Algorithm.
3+
* The Boyer–Moore string search algorithm allows linear time search by skipping indices
4+
* when searching inside a string for a pattern.
5+
*/
6+
7+
/**
8+
* Builds the bad match table for the Boyer-Moore algorithm based on the pattern.
9+
*@param {string} str The pattern string for which the bad match table is built.
10+
*@returns {Object} The bad match table object containing characters and their corresponding offsets.
11+
*/
1212
const buildBadMatchTable = (str) => {
1313
const tableObj = {}
1414
const strLength = str.length
@@ -21,6 +21,12 @@ const buildBadMatchTable = (str) => {
2121
return tableObj
2222
}
2323

24+
/**
25+
* Performs the Boyer-Moore string search algorithm to find a pattern in a given string.
26+
* @param {string} str The string in which to search for the pattern.
27+
* @param {string} pattern The pattern string to search for in the main string.
28+
* @returns {number} The index at which the pattern is found in the string, or -1 if not found.
29+
*/
2430
const boyerMoore = (str, pattern) => {
2531
const badMatchTable = buildBadMatchTable(pattern)
2632
let offset = 0
@@ -46,4 +52,5 @@ const boyerMoore = (str, pattern) => {
4652
}
4753
return -1
4854
}
55+
4956
export { boyerMoore }

‎String/CheckPalindrome.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
// Palindrome check is case sensitive; i.e. Aba is not a palindrome
2-
// input is a string
1+
/**
2+
* Checks if a string is a palindrome.
3+
* A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward.
4+
* Palindrome check is case sensitive; i.e., "Aba" is not considered a palindrome.
5+
* @param {string} str The input string to be checked for palindrome.
6+
* @returns {string} Returns 'Palindrome' if the input string is a palindrome,
7+
* 'Not a Palindrome' if it is not, or an error message if the input is not a valid string.
8+
*/
39
const checkPalindrome = (str) => {
410
// check that input is a string
511
if (typeof str !== 'string') {

‎String/CheckRearrangePalindrome.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Receives a string and returns whether it can be rearranged to become a palindrome or not
44
* The string can only be a palindrome if the count of ALL characters is even or if the ONLY ONE character count is odd
55
* Input is a string
6-
*
6+
* @param {string} str The input string to be checked for palindrome rearrangement.
7+
* @returns {boolean|string} Returns true if the string can be rearranged to form a palindrome,
8+
* false if it cannot, or an error message if the input is not a valid string.
79
**/
810

911
export const palindromeRearranging = (str) => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /