We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5244c0b commit 6713df9Copy full SHA for 6713df9
C++/LeetCodet题解(C++版).pdf
52 Bytes
C++/chapLinearList.tex
@@ -109,17 +109,18 @@ \subsubsection{代码1}
109
\begin{Code}
110
// LeetCode, Remove Duplicates from Sorted Array II
111
// 时间复杂度O(n),空间复杂度O(1)
112
+// @author hex108 (https://github.com/hex108)
113
class Solution {
114
public:
115
int removeDuplicates(int A[], int n) {
- if(n <= 2) return n;
116
-
+ if (n <= 2) return n;
117
+
118
int index = 2;
- for(int i = 2; i < n; i ++){
119
- if(A[i] != A[index - 2])
120
- A[index ++] = A[i];
+ for (int i = 2; i < n; i++){
+ if (A[i] != A[index - 2])
121
+ A[index++] = A[i];
122
}
123
124
return index;
125
126
};
0 commit comments