Skip to content
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

Added c++ cheatsheet #93

Closed
Closed
Show file tree
Hide file tree
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
Binary file added CheatSheets/CPP-Cheatsheet.pdf
Binary file not shown.
4 changes: 3 additions & 1 deletion LeetCode/Algorithms/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"initializer_list": "cpp",
"regex": "cpp",
"valarray": "cpp",
"ostream": "cpp"
"ostream": "cpp",
"xstring": "cpp",
"xlocale": "cpp"
}
}
5 changes: 5 additions & 0 deletions LeetCode/Algorithms/Easy/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"xlocale": "cpp"
}
}
19 changes: 19 additions & 0 deletions LeetCode/Algorithms/Easy/ReverseWordsInAString3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public:
string reverseWords(string s) {
stringstream ss(s);

string t;
string result = "";

while(getline(ss, t, ' ')) {
reverse(t.begin(), t.end());
result += t + ' ';
}
return result.substr(0, result.size() - 1);
}

};

// Time Complexity - O(N)
// Space Complexity - O(1)
45 changes: 45 additions & 0 deletions LeetCode/Algorithms/Hard/RestoreTheArray.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Solution {
public:
int numberOfArrays(string s, int k) {
vector<int> dp(s.size(), -1);

}
};


arr = [1,3,4,2],

mat =
0 1
0 [[1,4],
1 [2,3]]

mpr

1 0
4 0
2 1
3 1

mpc
1 0
4 1
2 0
3 1

mpr[1] = 0
mprc[mpr[1]] = 1
mpcc[mpc[1]] = 1

mpr[3] = 1
mpc[3] = 1

mprc[mpr[1]] = 2
mpcc[mpc[1]] = 2

mpr[4] = 1
mpc[4] = 1

mprc[mpr[1]] = 3
mpcc[mpc[1]] = 3;

Empty file.