#include <leetcode.h>
◆ numberOfWays()
long long leetcode::number_of_ways_to_select_buildings::Solution::numberOfWays |
( |
string |
s | ) |
|
|
static |
在文件 leetcode.cpp 第 5460 行定义.
5461 const unsigned int n = s.length();
5462 vector<unsigned int> prev0(n, 0);
5463 vector<unsigned int> prev1(n, 0);
5464 vector<unsigned int> post0(n, 0);
5465 vector<unsigned int> post1(n, 0);
5466 unsigned current0 = 0;
5467 unsigned current1 = 0;
5468 for(
int i = 0; i < n; i++) {
5469 prev0[i] = current0;
5470 prev1[i] = current1;
5479 for(
int i = n - 1; i >= 0; i--) {
5480 post0[i] = current0;
5481 post1[i] = current1;
5489 for(
unsigned i = 0; i < n; i++) {
5491 ans +=
static_cast<long long>(prev1[i]) * post1[i];
5493 ans +=
static_cast<long long>(prev0[i]) * post0[i];
该类的文档由以下文件生成: