Skip to content

Commit

Permalink
⚡ pass string as reference to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
iagorrr committed Jan 5, 2024
1 parent 22f93f9 commit b21dfd8
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vi manacher(string s) {
vi manacher(const string &s) {
string t2;
for (auto c : s) t2 += string("#") + c;
t2 = t2 + '#';
Expand All @@ -25,6 +25,7 @@ string longest_palindrome(const string &s) {
for (auto c : s) s2 += string("#") + c;
s2 = s2 + '#';

// refactor this to use cpp max and iterators arithmetic
int mpos = 0;
for (int i = 0; i < len(xs); i++) {
if (xs[i] > xs[mpos]) {
Expand Down

0 comments on commit b21dfd8

Please sign in to comment.