Create Time: 21st June 2024
Title: Discretization
status: UNFINISHED
dg-publish: false
Author:
- AllenYGY
tags:
- NOTE
created: 2024-06-21T18:09
updated: 2024-06-22T16:18
vector<int> discretization(vector<int> &a) {
vector<int> alls(a);
sort(alls.begin(), alls.end()); // 排序
alls.erase(unique(alls.begin(), alls.end()), alls.end()); //去重
for (int &x : a) { //重新赋值原数组
x = lower_bound(alls.begin(), alls.end(), x) - alls.begin();
}
return alls; //用于查表
}