initial commit

This commit is contained in:
wt
2026-04-08 15:12:07 +07:00
commit 942e4e2dc1
30 changed files with 297 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
executable('rmdupfromsortedarray', 'src/main.cpp', install: true)
+13
View File
@@ -0,0 +1,13 @@
#include "rmdupsfromsortedarray.hpp"
#include <cassert>
#include <iostream>
int main() {
std::vector<int> nums1 = {1,1,2};
int k1 = removeDuplicates(nums1);
for (int i = 0; i < k1; i++) {
std::cout << "num1: " << nums1[i] << std::endl;
}
std::cout << "k1: " << k1 << std::endl;
return 0;
}
@@ -0,0 +1,13 @@
#include <vector>
inline int removeDuplicates(std::vector<int> &nums) {
int n = nums.size();
int i = 0;
for (int j = 0; j < n; j++) {
if (nums[j] != nums[i]) {
nums[i + 1] = nums[j];
i++;
}
}
return i + 1;
}