adding leetcode problems

This commit is contained in:
Jidong Xiao
2023-09-26 12:19:09 -04:00
parent b4a5e201ee
commit 6eb5eb10a1
3 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
// note: using template here is completely unnecessary. this is just a demonstration of how to define a templated function.
class Solution {
public:
template <typename T>
T removeElement(vector<T>& nums, T val) {
int size = nums.size();
int j = 0;
for(int i=0;i<size;i++){
if(nums[i] != val){
nums[j] = nums[i];
j++;
}
}
return j;
}
};