File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ \subsubsection{使用栈}
7474// 使用栈,时间复杂度O(n),空间复杂度O(n)
7575class Solution {
7676public:
77- int longestValidParentheses(string s) {
77+ int longestValidParentheses(const string& s) {
7878 int max_len = 0, last = -1; // the position of the last ')'
7979 stack<int> lefts; // keep track of the positions of non-matching '(' s
8080
@@ -108,7 +108,7 @@ \subsubsection{Dynamic Programming, One Pass}
108108// @author 一只杰森(http://weibo.com/wjson)
109109class Solution {
110110public:
111- int longestValidParentheses(string s) {
111+ int longestValidParentheses(const string& s) {
112112 vector<int> f(s.size(), 0);
113113 int ret = 0;
114114 for (int i = s.size() - 2; i >= 0; --i) {
@@ -134,7 +134,7 @@ \subsubsection{两遍扫描}
134134// @author 曹鹏(http://weibo.com/cpcs)
135135class Solution {
136136public:
137- int longestValidParentheses(string s) {
137+ int longestValidParentheses(const string& s) {
138138 int answer = 0, depth = 0, start = -1;
139139 for (int i = 0; i < s.size(); ++i) {
140140 if (s[i] == '(' ) {
You can’t perform that action at this time.
0 commit comments