682. Baseball Game
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的更多相关文章
- 【Leetcode_easy】682. Baseball Game
problem 682. Baseball Game solution: 没想到使用vector! class Solution { public: int calPoints(vector<s ...
- LeetCode 682 Baseball Game 解题报告
题目要求 You're now a baseball game point recorder. Given a list of strings, each string can be one of t ...
- [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 ...
- 682. Baseball Game 棒球游戏 按字母处理
[抄题]: You're now a baseball game point recorder. Given a list of strings, each string can be one of ...
- [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 ...
- 【LeetCode】682. Baseball Game 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 使用栈模拟 日期 题目地址:https://leet ...
- 682. Baseball Game (5月28日)
解答(打败98.60%) class Solution { public: int calPoints(vector<string>& ops) { vector<int&g ...
- LeetCode All in One题解汇总(持续更新中...)
突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...
- 2017/11/9 Leetcode 日记
2017/11/9 Leetcode 日记 566. Reshape the Matrix In MATLAB, there is a very useful function called 'res ...
随机推荐
- CentOS7中编译安装redis5.0
1. 环境介绍 CentOS7 (未安装Development Tools) 2. 下载Redis5.0-rc3 wget -O redis-5.0-rc3.tar.gz https://github ...
- XMPP openfire Smack 即时通讯
重新整理下这篇文章. 这篇文章的主要任务是使用AndroidStudio,通过Openfire,利用XMPP协议完成一个可以即时通讯.拥有好友系统的聊天软件. 一.服务器配置与相关库 理论不多说,只谈 ...
- http://www.bugku.com:Bugku——备份是个好习惯(http://120.24.86.145:8002/web16/)
看了bugku的这道题,陌生又熟悉. 题目首先说[备份是个好习惯],访问网站只有一串字符,,,,,emmmmm,这句话表明人家经常做备份,所以咯,肯定在网站哪里备份有网页信息.嘻嘻 1 ...
- C#中委托
委托是一种安全地封装方法的类型,它与 C 和 C++ 中的函数指针类似.与 C 中的函数指针不同,委托是面向对象的.类型安全的和保险的.一个委托类型是代表与特定参数列表和返回类型的方法的引用类型.实例 ...
- bean生命周期_Junit测试使用factory模式
在面试某互联网_保险 公司, 被问到了spring中bean的生命周期,不禁联想到我们之前作 junit测试时,使用了Factory模式,而没有用Mock.
- [z]重建索引
https://blog.csdn.net/funnyfu0101/article/details/52961485 所有执行的结果是脚本命令集合,可以用来创建索引: a)在plsql中使用execu ...
- Vmware黑屏解决方法
此原因是显卡性能差,显示选项开启了3D加速导致的,具体修改步骤: 英文路径:VM->Settings->Hardware->Display 在右面的内容栏中将 Accelerate ...
- js 变量大小写
js对变量是区分大小写的.完毕.
- 在linux上创建slave节点
在slave机器上创建一登录用户,步骤如下: 切换至/usr/sbin目录,执行useradd -m test007 -d /home/test007,test007就是我们所创建的用户 执行su+ ...
- 25.mysql中的常用工具
25.mysql中的常用工具25.1 mysql客户端连接工具跳转至mysql安装目录下的bincd C:\Program Files\MySQL\MySQL Server 5.7\binmac下cd ...