Skip to content

Instantly share code, notes, and snippets.

@kangzhiheng
Last active August 7, 2019 08:40
Show Gist options
  • Save kangzhiheng/e27b1e672a4074492cd67edae0b91669 to your computer and use it in GitHub Desktop.
Save kangzhiheng/e27b1e672a4074492cd67edae0b91669 to your computer and use it in GitHub Desktop.
删除容器里的重复元素
// 删除容器里的重复元素
// 1. 排序;
sort(pStr.begin(), pStr.end());
// unique()返回的是容器里的重复元素的起始位置
pStr.erase(unique(pStr.begin(), pStr.end()), pStr.end());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment