Snippets Collections
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main()
{
    // Vector of integers
    std::vector<int> vecObj {11, 12, 13, 14, 15, 16, 12, 43, 12, 13, 11};

    // Sort the values in vector
    std::sort(vecObj.begin(), vecObj.end());

    // Remove duplicate values from vector
    vecObj.erase(std::unique(vecObj.begin(), vecObj.end()), vecObj.end());

    // print all elements of vector
    for(auto elem : vecObj) {
        std::cout<<elem << ", ";
    }

    return 0;
}
#include<bits/stdc++.h>
using namespace std;

string IntToString(int arr[], int k){
	string ans;

	for(int i = 0;i<k;i++){
		ans+= to_string(arr[i]);
	}
	return ans;
}

void StringToInt(string s){
	vector<int>v;
	map<int, int> mp;
	for(int i = 0;i<s.length();i++){
		v.push_back(s[i]-'0');
	}
	sort(v.begin(), v.end());
	for(int i = 0;i<v.size();i++){
		mp[v[i]]++;
	}
	cout<<"counting the frequency : \n";
	for(auto i:mp){
			cout<<i.first<<" "<<i.second<<endl;
	}
}

int main(){
	string s = "123343233434435";
	int brr[] = {2,3,4,5,6,7};
	int n = sizeof(brr)/sizeof(brr[0]);
	cout<<IntToString(brr, n)<<endl;
	StringToInt(s);
	return 0;
}
star

Thu May 25 2023 17:34:22 GMT+0000 (Coordinated Universal Time) https://devptr.com/how-to-remove-duplicates-from-a-vector-in-c/

#c++ #remove_duplicates #vector
star

Thu May 04 2023 13:52:40 GMT+0000 (Coordinated Universal Time) https://mavo.io/demos/svgpath/

#svg #path #vector
star

Mon Oct 10 2022 17:29:48 GMT+0000 (Coordinated Universal Time)

#frequency #string_to_int_array #int_to_string_array #vector #c++

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension