File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 56
56
### Strings
57
57
58
58
- [ 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 )
59
61
60
62
### Searching & Sorting
61
63
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments