summaryrefslogtreecommitdiff
path: root/c/0027
diff options
context:
space:
mode:
Diffstat (limited to 'c/0027')
-rw-r--r--c/0027/main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/c/0027/main.c b/c/0027/main.c
index cc104bb..dd5ab1b 100644
--- a/c/0027/main.c
+++ b/c/0027/main.c
@@ -1,3 +1,11 @@
int removeElement(int* nums, int numsSize, int val) {
-
-} \ No newline at end of file
+ int p = 0;
+ for (int i = 0; i < numsSize; i++) {
+ if (nums[i] == val) {
+ continue;
+ }
+ nums[p] = nums[i];
+ p++;
+ }
+ return p;
+}