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. JavaScript Validate a Valid Date formatted as "mm/dd/yyyy"

    // Validates that the input string is a valid date formatted as "mm/dd/yyyy" function isVa ...

  2. laravel5.6上传图片及显示

    借鉴大神博客:https://blog.csdn.net/tony_110/article/details/80105099文档:http://laravelacademy.org/post/8965 ...

  3. Asp.net中GridView使用详解(很全,很经典 转来的)

    Asp.net中GridView使用详解 效果图参考:http://hi.baidu.com/hello%5Fworld%5Fws/album/asp%2Enet中以gv开头的图片 l         ...

  4. spring上下文快速获取方法

    import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContex ...

  5. 什么是PCM?它和.wav文件是什么关系?

    PCM(Pulse Code Modulation----脉码调制录音).所谓PCM录音就是将声音等模拟信号变成符号化的脉冲列,再予以记录.PCM信号是由[1].[0]等符号构成的数字信号,而未经过任 ...

  6. 运行wmic命令异常:java.io.IOException: Cannot run program "wmic": CreateProcess error=2, ϵͳÕҲ»µ½ָ¶解决记录

    之前的一篇博文获取电脑cpu序列号在一同事电脑出现上述异常 百度一下网上只有一位外国网友朋友这个问题(地址),并且还没人回复,你能靠自己了 定位了一下出错代码: Process process = R ...

  7. xml添加新节点

    #!/usr/bin/env python #coding:utf-8 # Author: xiaobaichuangtianxia--<> # Purpose: add jacoco d ...

  8. jquery插件之选项卡

    jQuery插件编写 首先来一个简拓展jQuery对象的方法 <body > <p>23</p> <script src="js/jquery-1. ...

  9. mybatis入门--#{}和${}的区别

    我们知道,在mybatis中,sql语句是需要我们自己写的.跟在普通的sql不一样的是,我们在使用mybatis框架的时候,使用的占位符不是 ? 而是 #{} 有时候还会出现这个符号 ${} 这些符号 ...

  10. java8 数据结构的改变(一)

    在JDK1.6,JDK1.7中,HashMap采用数组+链表实现,即使用链表处理冲突,同一hash值的链表都存储在一个链表里.但是当数组中一个位置上的元素较多,即hash值相等的元素较多时,通过key ...