File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ \subsubsection{使用栈}
74
74
// 使用栈,时间复杂度O(n),空间复杂度O(n)
75
75
class Solution {
76
76
public:
77
- int longestValidParentheses(string s) {
77
+ int longestValidParentheses(const string& s) {
78
78
int max_len = 0, last = -1; // the position of the last ')'
79
79
stack<int> lefts; // keep track of the positions of non-matching '(' s
80
80
@@ -108,7 +108,7 @@ \subsubsection{Dynamic Programming, One Pass}
108
108
// @author 一只杰森(http://weibo.com/wjson)
109
109
class Solution {
110
110
public:
111
- int longestValidParentheses(string s) {
111
+ int longestValidParentheses(const string& s) {
112
112
vector<int> f(s.size(), 0);
113
113
int ret = 0;
114
114
for (int i = s.size() - 2; i >= 0; --i) {
@@ -134,7 +134,7 @@ \subsubsection{两遍扫描}
134
134
// @author 曹鹏(http://weibo.com/cpcs)
135
135
class Solution {
136
136
public:
137
- int longestValidParentheses(string s) {
137
+ int longestValidParentheses(const string& s) {
138
138
int answer = 0, depth = 0, start = -1;
139
139
for (int i = 0; i < s.size(); ++i) {
140
140
if (s[i] == '(' ) {
You can’t perform that action at this time.
0 commit comments