-
-
Notifications
You must be signed in to change notification settings - Fork 130
Add cpp basics #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cpp basics #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
}, | ||
{ | ||
"title": "Split String", | ||
"description": "Splits a string by a delimiter", | ||
"description": "Splits a string by a delimiter.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please remove the |
||
"code": [ | ||
"#include <string>", | ||
"#include <vector>", | ||
|
@@ -58,6 +58,30 @@ | |
], | ||
"tags": ["cpp", "string", "split", "utility"], | ||
"author": "saminjay" | ||
}, | ||
{ | ||
"title": "Palindrome Check", | ||
"description": "Checks if a given string is a palindrome (reads the same forwards and backwards).", | ||
"code": [ | ||
"#include <string>", | ||
"", | ||
"// Function to check if a given string is a palindrome", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comments are generally not required in the snippet. |
||
"bool isPalindrome(const std::string& str) {", | ||
" int left = 0;", | ||
" int right = str.length() - 1;", | ||
" ", | ||
" // Compare characters from both ends", | ||
" while (left < right) {", | ||
" if (str[left] != str[right]) // If characters don't match, it's not a palindrome", | ||
" return false;", | ||
" left++;", | ||
" right--;", | ||
" }", | ||
" return true; // If all characters match, it's a palindrome", | ||
"}" | ||
], | ||
"tags": ["cpp", "string", "palindrome", "utility"], | ||
"author": "ohhpeejoshi" | ||
} | ||
] | ||
} | ||
|