Skip to content

DarlynND/rescursion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Idea

A word is a palindrome if it reads the same forward and backward.

Algorithm (step by step)

If the word is empty or has one character → palindrome.

Compare the first and last characters:

If they are different → not a palindrome.

If they are the same → repeat the process on the word without the first and last characters.

Continue until a stop condition is reached.

Example (recursive solution in JavaScript) function isPalindrome(word) { if (word.length <= 1) { return true; } if (word[0] !== word[word.length - 1]) { return false; } return isPalindrome(word.slice(1, -1)); }

Examples

gag → true

kayak → true

php → true

hello → false

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors