problem

682. Baseball Game

solution:

没想到使用vector!

class Solution {
public:
int calPoints(vector<string>& ops) {
vector<int> v;
for(auto ch:ops)
{
if(ch=="+") v.push_back(v.back()+v[v.size()-]);//err.
else if(ch=="D") v.push_back(*v.back());
else if(ch=="C") v.pop_back();
else v.push_back(stoi(ch));
}
return accumulate(v.begin(), v.end(), );//err.
}
};

参考

1. Leetcode_easy_682. Baseball Game;

2. Grandyang;

【Leetcode_easy】682. Baseball Game的更多相关文章

  1. 【LeetCode】682. Baseball Game 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 使用栈模拟 日期 题目地址:https://leet ...

  2. 【Leetcode_easy】1021. Remove Outermost Parentheses

    problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完

  3. 【Leetcode_easy】1022. Sum of Root To Leaf Binary Numbers

    problem 1022. Sum of Root To Leaf Binary Numbers 参考 1. Leetcode_easy_1022. Sum of Root To Leaf Binar ...

  4. 【Leetcode_easy】1025. Divisor Game

    problem 1025. Divisor Game 参考 1. Leetcode_easy_1025. Divisor Game; 完

  5. 【Leetcode_easy】1029. Two City Scheduling

    problem 1029. Two City Scheduling 参考 1. Leetcode_easy_1029. Two City Scheduling; 完

  6. 【Leetcode_easy】1030. Matrix Cells in Distance Order

    problem 1030. Matrix Cells in Distance Order 参考 1. Leetcode_easy_1030. Matrix Cells in Distance Orde ...

  7. 【Leetcode_easy】1033. Moving Stones Until Consecutive

    problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...

  8. 【Leetcode_easy】1037. Valid Boomerang

    problem 1037. Valid Boomerang 参考 1. Leetcode_easy_1037. Valid Boomerang; 完

  9. 【Leetcode_easy】1042. Flower Planting With No Adjacent

    problem 1042. Flower Planting With No Adjacent 参考 1. Leetcode_easy_1042. Flower Planting With No Adj ...

随机推荐

  1. PL/SQL复合类型

    一.PL/SQL记录:一条记录. 可简化单行多列的数据的处理.当使用pl/sql记录时,应用开发人员即可以自定义记录类型和记录变量,也可以使用%rowtype属性直接定义记录变量. 1.当使用自定义的 ...

  2. 基于pg_qualstats和hypopg的自动索引调优

    pg-qualstats的安装和配置 1.安装pg-qualstats -pg-qualstats 2.将pg_qualstats和pg_stat_statements添加到shared_preloa ...

  3. Apicloud 之按两次后退键退出应用

    api.addEventListener({ name: 'keyback' }, function(ret, err) { if (flag == 1) { api.closeWidget({ si ...

  4. python func(*args, **kwargs)

    func(*args, **kwargs) *args, **kwargs表示函数的可变参数 *args 表示任何多个无名参数,它是一个tuple **kwargs 表示关键字参数,它是一个dict ...

  5. PHP流程控制之嵌套if...else...elseif结构

    还记得本章开篇我们讲了一个王思总同学的例子: 王同学是生活极度充满娱乐化和享受生活的人.他抵达北京或者大连的时候做的事,他抵达后做的事情,如下:直线电机参数 半夜到达,先去夜店参加假面舞会 早上抵达, ...

  6. 异常:ORA-01013: 用户请求取消当前的操作

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/bnmnba/article/detail ...

  7. LOJ P10147 石子合并 题解

    Analysis 区间dp+前缀和 #include<iostream> #include<cstdio> #include<cstring> #include&l ...

  8. 利用QSystemSemaphore和QSharedMemory实现进程间通讯

    https://blog.csdn.net/liji_digital/article/details/70547082 线程间的通讯可以由QSemaphore调控,以保证各个线程对同一资源的访问不冲突 ...

  9. notepad++修改背景色

  10. [WEB安全]phpMyadmin后台任意文件包含漏洞分析(CVE-2018-12613)

    0x00 简介 影响版本:4.8.0--4.8.1 本次实验采用版本:4.8.1 0x01 效果展示 payload: http://your-ip:8080/index.php?target=db_ ...