forked from trekhleb/javascript-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code/README fixes for the "Palindrome Check".
- Loading branch information
Showing
6 changed files
with
48 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/algorithms/string/palindrome-check/__test__/palindromeCheck.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Palindrome Check | ||
|
||
A [Palindrome](https://en.wikipedia.org/wiki/Palindrome) is a string that reads the same forwards and backwards. | ||
This means that the second half of the string is the reverse of the | ||
first half. | ||
|
||
## Examples | ||
|
||
The following are palindromes (thus would return `TRUE`): | ||
|
||
``` | ||
- "a" | ||
- "pop" -> p + o + p | ||
- "deed" -> de + ed | ||
- "kayak" -> ka + y + ak | ||
- "racecar" -> rac + e + car | ||
``` | ||
|
||
The following are NOT palindromes (thus would return `FALSE`): | ||
|
||
``` | ||
- "rad" | ||
- "dodo" | ||
- "polo" | ||
``` | ||
|
||
## References | ||
|
||
- [GeeksForGeeks - Check if a number is Palindrome](https://www.geeksforgeeks.org/check-if-a-number-is-palindrome/) |
15 changes: 15 additions & 0 deletions
15
src/algorithms/string/palindrome/__test__/isPalindrome.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import isPalindrome from '../isPalindrome'; | ||
|
||
describe('palindromeCheck', () => { | ||
it('should return whether or not the string is a palindrome', () => { | ||
expect(isPalindrome('a')).toBe(true); | ||
expect(isPalindrome('pop')).toBe(true); | ||
expect(isPalindrome('deed')).toBe(true); | ||
expect(isPalindrome('kayak')).toBe(true); | ||
expect(isPalindrome('racecar')).toBe(true); | ||
|
||
expect(isPalindrome('rad')).toBe(false); | ||
expect(isPalindrome('dodo')).toBe(false); | ||
expect(isPalindrome('polo')).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters