From 13d2cc19ada9e9406b2c0148c97c36b96655925c Mon Sep 17 00:00:00 2001 From: Hardik Date: Mon, 29 Sep 2025 01:56:32 +0530 Subject: [PATCH 1/3] Add palindrome check algorithm in strings/ --- strings/is_palindrome.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 strings/is_palindrome.py diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py new file mode 100644 index 000000000000..345e35d31e5c --- /dev/null +++ b/strings/is_palindrome.py @@ -0,0 +1,14 @@ +def is_palindrome(text: str) -> bool: + """ + Check if a string is a palindrome. + >>> is_palindrome("radar") + True + >>> is_palindrome("hello") + False + """ + return text == text[::-1] + + +if __name__ == "__main__": + import doctest + doctest.testmod() From f82e16c53bb0a5d7775cc6da8ff0862fe219d34f Mon Sep 17 00:00:00 2001 From: Hardik Date: Mon, 29 Sep 2025 02:02:23 +0530 Subject: [PATCH 2/3] Add palindrome check algorithm with reference URL --- strings/is_palindrome.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index 345e35d31e5c..d75db4788069 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -1,10 +1,19 @@ def is_palindrome(text: str) -> bool: """ Check if a string is a palindrome. + + A palindrome is a word, number, phrase, or other sequence of + characters which reads the same backward as forward. + + Reference: https://en.wikipedia.org/wiki/Palindrome + + Examples: >>> is_palindrome("radar") True >>> is_palindrome("hello") False + >>> is_palindrome("level") + True """ return text == text[::-1] From f185b1aac3f1b516812c32f648974af8fdcc3149 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:34:01 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/is_palindrome.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index d75db4788069..79554f166484 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -2,7 +2,7 @@ def is_palindrome(text: str) -> bool: """ Check if a string is a palindrome. - A palindrome is a word, number, phrase, or other sequence of + A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward. Reference: https://en.wikipedia.org/wiki/Palindrome @@ -20,4 +20,5 @@ def is_palindrome(text: str) -> bool: if __name__ == "__main__": import doctest + doctest.testmod()