Skip to content

Commit fcafa71

Browse files
Merge pull request #2147 from CodingTestStudy2/염혜정
[염혜정] 2026/10/08
2 parents 624ef25 + 52f85aa commit fcafa71

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// 투포인터
2+
// O(n)
3+
4+
class Solution {
5+
public int removeDuplicates(int[] nums) {
6+
int now = 1;
7+
for (int next = 1; next<nums.length; next++) {
8+
if (nums[next] != nums[now-1]) {
9+
nums[now] = nums[next];
10+
now++;
11+
}
12+
}
13+
return now;
14+
}
15+
}

0 commit comments

Comments
 (0)