26. Remove Duplicates from Sorted Array
·
Coding Test/LeetCode
class Solution { public: int removeDuplicates(vector& nums) { int k =1; int j=nums[0]; vector nums2; nums2.push_back(j); for(int i =1;i
80. Remove Duplicates from Sorted Array II
·
Coding Test/LeetCode
class Solution { public: int removeDuplicates(vector& nums) { int n =nums.size(); if(n
27. Remove Element
·
Coding Test/LeetCode
class Solution { public: int removeElement(vector& nums, int val) { int k=0; vector index; for(auto iter=nums.begin();iter!=nums.end();iter++) { if(*iter!=val) { index.push_back(*iter); k++; } } nums=index; return k; } };
88. Merge Sorted Array
·
Coding Test/LeetCode
class Solution { public: void merge(vector& nums1, int m, vector& nums2, int n) { for(int i=m;i