Algorithm Intro - Count Sort
来源:互联网 发布:淘宝客教学视频 编辑:程序博客网 时间:2024/05/29 16:28
void count_sort(vector<int> &v, vector<int>&res)
{
int t = 0;
vector<int> r, c;
r.assign(4096, 0);
for(int i = 0; i < r.size(); i++) r[i] = 0;
c = r;
res = r;
for(int i = 0; i < v.size(); i++) {
r[v[i]]++;
c[v[i]]++;
}
for(int i = 1; i < c.size(); i++) {
c[i] += c[i - 1];
}
for(int i = v.size() - 1; i >= 0; i--) {
res[c[v[i]] - 1] = v[i];
c[v[i]]--;
// or res[--c[v[i]]] = v[i];
}
0 0
- Algorithm Intro - Count Sort
- Algorithm Intro - Insert Sort
- Algorithm intro - Select Sort
- Algorithm Intro - Bubble Sort
- Algorithm Intro - Merge Sort
- Algorithm Intro - Quick Sort
- Algorithm Intro - Radix Sort
- [1_3_milk] O(n) algorithm <Count sort>
- sort algorithm
- sort algorithm
- Sort algorithm
- Sort Algorithm-->Bubble Sort
- Sort Algorithm-->Select Sort
- STL Algorithm::Count()
- STL algorithm count demo
- STL algorithm count() demo
- algorithm count 函数
- Sort algorithm overview.
- spi子系统 赏析
- [python语法巩固][leetcode326][Power of Three]
- Linux系统中System.map的解析
- C++学习笔记41——重载操作符之下标操作符
- Codeforces Round #334 (Div. 2) C. Alternative Thinking
- Algorithm Intro - Count Sort
- HDOJ 1290 献给杭电五十周年校庆的礼物 (数学—平面分割空间)
- struts2 基于XML配置方式实现校验(指定方法)
- 反射之获取父类
- 概率、随机数、随机数生成函数(面试题)
- HDU 1254:推箱子【DFS && BFS】
- 人见人爱A+B(2)
- Fragment详解之二——基本使用方法
- C#调用C++ DLL 中定义的函数