8000 Added const reference · BenjaminUJun/leetcode_Java@13ba26c · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 13ba26c

Browse files
committed
Added const reference
1 parent 7611b95 commit 13ba26c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

C++/chapStackAndQueue.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ \subsubsection{使用栈}
7474
// 使用栈,时间复杂度O(n),空间复杂度O(n)
7575
class Solution {
7676
public:
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)
109109
class Solution {
110110
public:
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)
135135
class Solution {
136136
public:
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] == '(') {

0 commit comments

Comments
 (0)
0