Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions public/data/cpp.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,39 @@
"title": "Reverse String",
"description": "Reverses the characters in a string.",
"code": [
"string reverseString(const string& input) {",
" string reversed = input;",
" reverse(reversed.begin(), reversed.end()); // Using STL's reverse function",
"#include <string>",
"#include <algorithm>",
"",
"std::string reverseString(const std::string& input) {",
" std::string reversed = input;",
" std::reverse(reversed.begin(), reversed.end());",
" return reversed;",
"}"
],
"tags": ["cpp", "array", "reverse", "utility"],
"author": "Vaibhav-kesarwani"
},
{
"title": "Split String",
"description": "Splits a string by a delimiter",
"code": [
"#include <string>",
"#include <vector>",
"",
"std::vector<std::string> split_string(std::string str, std::string delim) {",
" std::vector<std::string> splits;",
" int i = 0, j;",
" int inc = delim.length();",
" while (j != std::string::npos) {",
" j = str.find(delim, i);",
" splits.push_back(str.substr(i, j - i));",
" i = j + inc;",
" }",
" return splits;",
"}"
],
"tags": ["cpp", "string", "split", "utility"],
"author": "saminjay"
}
]
}
Expand Down