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

#include <leetcode.h>

静态 Public 成员函数

static vector< vector< int > > construct2DArray (vector< int > &original, int m, int n)
 

详细描述

在文件 leetcode.h171 行定义.

成员函数说明

◆ construct2DArray()

vector< vector< int > > leetcode::convert_1d_array_into_2d_array::Solution::construct2DArray ( vector< int > &  original,
int  m,
int  n 
)
static

在文件 leetcode.cpp284 行定义.

284 {
285 if(original.size() != static_cast<unsigned long long>(m) * static_cast<unsigned long long>(n)) {
286 return {};
287 }
288 auto ans = vector<vector<int>>();
289 int count = 0;
290 for(int i = 0; i < m; i++) {
291 auto row = vector<int>();
292 for(int j = 0; j < n; j++) {
293 row.push_back(original[count++]);
294 }
295 ans.push_back(row);
296 }
297 return ans;
298 }

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


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