1、构造题目所需的排序方法,例如根据 两数之差 从小到大排列:
1 | vector<vector<int>>tasks = {{1,3},{2,4},{10,11}, {10,12},{8,9}}; |
2、根据第n个值来排序
tasks = [[2,3,1],[4,5,1],[1,5,2]]
1 | sort(tasks.begin(), tasks.end(), [](auto &a, auto &b) { |
输出 [[2,3
,1],[4,5
,1],[1,5
,2]]
(Golang版本)
1 | task := [][]int{{2, 3, 1}, {4, 5, 1}, {1, 5, 2}} // start,end,duration |