当前位置:网站首页>Greedy two-dimensional array sorting
Greedy two-dimensional array sorting
2022-06-30 14:37:00 【Douglas_ LT】
A daily topic ing, Today is a day medium topic 406. Rebuild the queue according to height
class Solution {
public:
static bool cmp(const vector<int> a, const vector<int> b) {
if (a[0] == b[0]) return a[1] < b[1];
return a[0] > b[0];
}
vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
sort (people.begin(), people.end(), cmp);
vector<vector<int>> que;
for (int i = 0; i < people.size(); i++) {
int position = people[i][1];
que.insert(que.begin() + position, people[i]);
}
return que;
}
};
边栏推荐
- go time. after
- Detailed explanation of settimeout() and setinterval()
- Detailed explanation of the first three passes of upload Labs
- PHP multidimensional array sorting
- @Component use cases
- How does hbuilder display in columns?
- The programming competition is coming! B station surrounding, senior members and other good gifts to you!
- Go language for loop multivariable use
- Experiment 2: stack
- Laravel8 custom log directory, rename
猜你喜欢
Thinkphp5 log file contains trick
Race of golang
Shangpinhui knowledge points of large e-commerce projects
Crypto questions
Introduction to the construction and development of composer private warehouse
"Persistent diseases" that cannot be solved in IM application development
JS to realize simple lottery function
Clear the route cache in Vue
How to use Alibaba Vector Icon
Go language mutex lock
随机推荐
@ResponseBody的作用
An error is reported when installing dataspherestudio doc: invalid default value for 'update_ time‘
@component使用案例
Learn about data kinship JSON format design from sqlflow JSON format
Use PHP to delete the specified text content in the file
Fastcgi CGI shallow understanding
Use of laravel repository mode
Cost forecast of PMP (BAC, EAC, etc)
ES6 notes
PHP recursive multi-level classification, infinite classification
Four isolation levels of MySQL
Details of gets, fgetc, fgets, Getc, getchar, putc, fputc, putchar, puts, fputs functions
KnightCTF WEB
NoViableAltException([email protected][])
Initial attack and defense world Misc
Solution cannot use a scalar value as an array
Effect of shadow around the block after mouse over
Dart extended feature
PS dynamic drawing
[extensive reading of papers] analyzing connections between user attributes, images, and text