std::sort(str.begin(), str.end())
a.append(a.end(), b.begin(), b.end())
// return an iterator
std::find(v.begin(), v.end(), value)
#include <numeric>
int sum = std::accumulate(v.begin(), v.end(), 0);
#include <algorithm>
ForwardIterator it = std::min_element (v.begin(), v.end() );
nth_element(v.begin(), v.begin() + k, v.end(), std::greater<int>())
The elements from v.begin() to v.begin() + k are k largest elements
v.erase(std::remove_if( v.begin(), v.end(), [](const int& x) {
return x > 10; // put your condition here
}), v.end());
#include "stdafx.h"
#include <sstream>
#include <algorithm>
using namespace std;
vector<string> split(string s, char delim)
{
vector<string> elem;
std::stringstream ss(s);
string item;
while (std::getline(ss, item, delim))
{
elem.push_back(item);
}
return elem;
}
stoi
string to int
atoi
char* to int
#include <string>
#include <algirhtm>
std::transform(s.begin(), s.end(), s.begin(), tolower);
template <typename T>
Struct comparator
{
Bool operator() (T a, T b)
{
Return a < b;
}
};
Std::priority_queue<int, std::vector<int>, comparator<int>> max_heap;
We can use multiset to represent a BST.
We can create min-heap by set the comparator as greater
#include <functional>
std::priority_queue<int, vector<int>, std::greater<int>> minHeap