Skip to content

Commit 6713df9

Browse files
committed
merge hex108's code
1 parent 5244c0b commit 6713df9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

C++/LeetCodet题解(C++版).pdf

52 Bytes
Binary file not shown.

C++/chapLinearList.tex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,18 @@ \subsubsection{代码1}
109109
\begin{Code}
110110
// LeetCode, Remove Duplicates from Sorted Array II
111111
// 时间复杂度O(n),空间复杂度O(1)
112+
// @author hex108 (https://github.com/hex108)
112113
class Solution {
113114
public:
114115
int removeDuplicates(int A[], int n) {
115-
if(n <= 2) return n;
116-
116+
if (n <= 2) return n;
117+
117118
int index = 2;
118-
for(int i = 2; i < n; i ++){
119-
if(A[i] != A[index - 2])
120-
A[index ++] = A[i];
119+
for (int i = 2; i < n; i++){
120+
if (A[i] != A[index - 2])
121+
A[index++] = A[i];
121122
}
122-
123+
123124
return index;
124125
}
125126
};

0 commit comments

Comments
 (0)