#include <leetcode.h>
|
static vector< int > | diffWaysToCompute (const string &expression) |
|
static vector< int > | eval (const string &expr, int start, int end) |
|
◆ diffWaysToCompute()
vector< int > leetcode::different_ways_to_add_parentheses::Solution::diffWaysToCompute |
( |
const string & | expression | ) |
|
|
static |
◆ eval()
vector< int > leetcode::different_ways_to_add_parentheses::Solution::eval |
( |
const string & | expr, |
|
|
int | start, |
|
|
int | end ) |
|
static |
在文件 leetcode.cpp 第 8452 行定义.
8452 {
8454 bool allDigit = true;
8455 for(int i = start; i <= end; i++) {
8456 if(!isdigit(expr[i])) {
8457 allDigit = false;
8458 vector
left =
eval(expr, start, i - 1);
8460 for(const auto &l: left) {
8461 for(const auto &r: right) {
8462 switch(expr[i]) {
8463 case '+':
8464 ans.emplace_back(l + r);
8465 break;
8466 case '-':
8467 ans.emplace_back(l - r);
8468 break;
8469 case '*':
8470 ans.emplace_back(l * r);
8471 break;
8472 }
8473 }
8474 }
8475 }
8476 }
8477 if(allDigit) {
8478 int val = 0;
8479 for(int i = start; i <= end; i++) {
8480 val *= 10;
8481 val += expr[i] - '0';
8482 }
8483 ans.emplace_back(val);
8484 }
8486 }
引用了 eval().
被这些函数引用 diffWaysToCompute() , 以及 eval().
该类的文档由以下文件生成: