static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
int calPoints(vector<string>& ops)
{
int lastvalid=;
int sz=ops.size();
vector<int> sore(sz+,INT_MIN);
for(string &s:ops)
{
if(s[]=='+')
{
sore[lastvalid]=sore[lastvalid-]+sore[lastvalid-];
lastvalid++;
}
else if(s[]=='D')
{
sore[lastvalid]=sore[lastvalid-]*;
lastvalid++;
}
else if(s[]=='C')
lastvalid--;
else
sore[lastvalid++]=stoi(s);
}
return accumulate(sore.begin(),sore.begin()+lastvalid,);
}
};

用栈或者vector都行,string转int可以直接stoi,学到了,妈个腿

682. Baseball Game的更多相关文章

  1. 【Leetcode_easy】682. Baseball Game

    problem 682. Baseball Game solution: 没想到使用vector! class Solution { public: int calPoints(vector<s ...

  2. LeetCode 682 Baseball Game 解题报告

    题目要求 You're now a baseball game point recorder. Given a list of strings, each string can be one of t ...

  3. [LeetCode&Python] Problem 682. Baseball Game

    You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...

  4. 682. Baseball Game 棒球游戏 按字母处理

    [抄题]: You're now a baseball game point recorder. Given a list of strings, each string can be one of ...

  5. [LeetCode] 682. Baseball Game 棒球游戏

    You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...

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

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

  7. 682. Baseball Game (5月28日)

    解答(打败98.60%) class Solution { public: int calPoints(vector<string>& ops) { vector<int&g ...

  8. LeetCode All in One题解汇总(持续更新中...)

    突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...

  9. 2017/11/9 Leetcode 日记

    2017/11/9 Leetcode 日记 566. Reshape the Matrix In MATLAB, there is a very useful function called 'res ...

随机推荐

  1. Zabbix配置优化

    1.zabbix开启中文语言zabbix是一个多语言监控系统,默认使用英文并且也支持中文语言,详见<zabbix汉化方法>,但是安装zabbix里面看不到中文语言.请往下看: ![](ht ...

  2. 22. Generate Parentheses (backTracking)

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  3. 转:JMeter压力测试及并发量计算

    最近的一个项目刚刚开发完,因为不是专业测试人员,所以记录下测试过程以备时间长忘记了. 一.JMeter的安装(Linux)1. 下载JMeter:这个就不细说了,直接去(http://jmeter.a ...

  4. vue 打包

    1.assetsPublicPath路径改为‘./’(两处) 2.cmd运行  cnpm run build 3.生成的dist文件即可本地访问

  5. FortiGate密码恢复

    1.需求 1.若设备的密码忘记,需要用配置线进行密码恢复: 2.密码恢复需要重启设备,并在设备的底层菜单界面上操作,会造成网络中断,请在方便断网时操作: 3.密码恢复后配置不会改变. 2.操作步骤 1 ...

  6. 34-BigInteger详解

    在用C或者C++处理大数时感觉非常麻烦,但是在Java中有两个类BigInteger和BigDecimal分别表示大整数类和大浮点数类,至于两个类的对象能表示最大范围不清楚,理论上能够表示无线大的数, ...

  7. 实现mapper接口注入的两种方式,以及后台的使用区别

    1.使用模板方式: <!--使用模板类实现mybatis --> <bean id="sqlSession" class="org.mybatis.sp ...

  8. pyinstller的安装

    下载:http://www.pyinstaller.org/ 解压到目录 切换到python目录 执行命令: python.exe D:\Download\PyInstaller-2.1\setup. ...

  9. jQuery 实例

    选择器 $(this).hide() 隐藏当前的 HTML 元素. $("p").hide() 隐藏所有 <p> 元素. $(".test").hi ...

  10. Oracle 修改字段顺序的两种方法

    分类: Oracle 如果要修改字段顺序,一般情况可以使用以下步骤: --(1)备份目标表数据 create table 临时表 as select * from 目标表; --(2)drop 目标表 ...