当前位置:网站首页>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;
}
};
边栏推荐
- Is it troublesome for CITIC futures to open an account? Is it safe? How much is the handling charge for opening an account for futures? Can you offer a discount
- JMeter transaction controller
- Invalid argument during startup: Failed to open the . conf file: redis-window
- Uniapp upload image method
- Shangpinhui knowledge points of large e-commerce projects
- V3 03_ Getting started
- Pytoch viewing model parameter quantity and calculation quantity
- Detailed explanation of the first three passes of upload Labs
- JS array
- Summary of FTP network protocol learning
猜你喜欢

"Persistent diseases" that cannot be solved in IM application development

Introduction to the construction and development of composer private warehouse

How does hbuilder display in columns?

How to use Alibaba Vector Icon

Thinkphp5 log file contains trick

PS dynamic drawing

Error $(...) size is not a function

2021 geek challenge Web

Crypto questions

Component communication mode
随机推荐
PHP common authentication / third-party methods
On simple code crawling Youdao translation_ 0's problem (to be solved)
PHP multidimensional array sorting
Mutex lock, read / write lock, spin lock, pessimistic lock, and optimistic lock
Alipay certificate mode payment interface
Go language func function
Laravel artist command error
@PathVariable
JS array sorting method summary
PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available
Introduction to the renewal of substrate source code: the pallet alliance is incorporated into the main line,
Lfi-rce without controllable documents
Pit used by go language array type
【BUUCTF】 EasySql
jsPlumb. Deleteeveryconnection is not a function & jsplumb clear canvas jsplumb delete all nodes and all connections
Detailed explanation of the first three passes of upload Labs
LeetCode_ Stack_ Medium_ 227. basic calculator II (without brackets)
JS to realize simple lottery function
LIS error: this configuration section cannot be used in this path
ES6 notes