problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::rearrange_array_elements_by_sign::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static vector< int > rearrangeArray (vector< int > &nums)
 

详细描述

在文件 leetcode.h650 行定义.

成员函数说明

◆ rearrangeArray()

vector< int > leetcode::rearrange_array_elements_by_sign::Solution::rearrangeArray ( vector< int > &  nums)
static

在文件 leetcode.cpp1464 行定义.

1464 {
1465 const auto size = nums.size();
1466 auto ans = vector<int>();
1467 auto positive = vector<int>();
1468 auto negative = vector<int>();
1469 for(auto num: nums) {
1470 if(num > 0) {
1471 positive.push_back(num);
1472 } else {
1473 negative.push_back(num);
1474 }
1475 }
1476 for(int i = 0; i < size / 2; i++) {
1477 ans.push_back(positive[i]);
1478 ans.push_back(negative[i]);
1479 }
1480 return ans;
1481 }

被这些函数引用 leetcode::rearrange_array_elements_by_sign::TEST().


该类的文档由以下文件生成: