Skip to content

Commit 58606a2

Browse files
committed
palendrome
1 parent 1f6d07e commit 58606a2

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

DSA Crack Sheet/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
### Strings
5757

5858
- [Reverse String](https://leetcode.com/problems/reverse-string/ "view question") - [Cpp Solution](./solutions/Reverse%20String.cpp)
59+
- [Palindrome String](https://practice.geeksforgeeks.org/problems/palindrome-string0817/1 "view question") - [Cpp Solution](./solutions/Palindrome%20String.cpp)
60+
- []( "view question") - [Cpp Solution](./solutions/.cpp)
5961

6062
### Searching & Sorting
6163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Palindrome String
3+
=================
4+
5+
Given a string S, check if it is palindrome or not.
6+
7+
Example 1:
8+
Input: S = "abba"
9+
Output: 1
10+
Explanation: S is a palindrome
11+
12+
Example 2:
13+
Input: S = "abc"
14+
Output: 0
15+
Explanation: S is not a palindrome
16+
17+
Your Task:
18+
You don't need to read input or print anything. Complete the function isPlaindrome() which accepts string S and returns a boolean value
19+
20+
Expected Time Complexity: O(Length of S)
21+
Expected Auxiliary Space: O(1)
22+
23+
Constraints:
24+
1 <= Length of S <= 105
25+
*/
26+
27+
int isPlaindrome(string s)
28+
{
29+
for (int i = 0; i < s.size() / 2; ++i)
30+
{
31+
if (s[i] != s[s.size() - 1 - i])
32+
return 0;
33+
}
34+
return 1;
35+
}

0 commit comments

Comments
 (0)