【Leetcode_easy】682. Baseball Game
problem
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的更多相关文章
- 【LeetCode】682. Baseball Game 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 使用栈模拟 日期 题目地址:https://leet ...
- 【Leetcode_easy】1021. Remove Outermost Parentheses
problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完
- 【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 ...
- 【Leetcode_easy】1025. Divisor Game
problem 1025. Divisor Game 参考 1. Leetcode_easy_1025. Divisor Game; 完
- 【Leetcode_easy】1029. Two City Scheduling
problem 1029. Two City Scheduling 参考 1. Leetcode_easy_1029. Two City Scheduling; 完
- 【Leetcode_easy】1030. Matrix Cells in Distance Order
problem 1030. Matrix Cells in Distance Order 参考 1. Leetcode_easy_1030. Matrix Cells in Distance Orde ...
- 【Leetcode_easy】1033. Moving Stones Until Consecutive
problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...
- 【Leetcode_easy】1037. Valid Boomerang
problem 1037. Valid Boomerang 参考 1. Leetcode_easy_1037. Valid Boomerang; 完
- 【Leetcode_easy】1042. Flower Planting With No Adjacent
problem 1042. Flower Planting With No Adjacent 参考 1. Leetcode_easy_1042. Flower Planting With No Adj ...
随机推荐
- Django连接MySQL数据库配置
1.自己手动创建数据库 create database 数据库名; # 如: create database bms character set utf8; # 授权访问: grant all pri ...
- hibernate meger
转: 在Hibernate中,有save.persist.savaOrUpdate.merge等方法有插入数据的功能.前三者理解起来较后者容易一些,merge方法从api中的介绍就看以看出它是最复杂的 ...
- 1~n中数字0~9出现的次数
题意:rt 分析: 当然不可能去遍历,应该寻找统计的方法. 如计算 78501 中 "5" 出现的次数. 我们可以枚举“5”出现的位置, 如当“5”位于倒数第2位时,写成 xxx5 ...
- 20191029 牛客CSP-S提高组赛前集训营1
前一个小时看这几道题感觉要爆零 A. 仓鼠的石子游戏 分析一下发现a[i]>1a[i]>1a[i]>1时后先手必输,a[i]=1a[i]=1a[i]=1时先手必赢 然后直接看1的个数 ...
- 011——C#创建ecxel文件(附教程)
(一)参考文献:[C#]创建表格(.xlsx)的典型方法 (二)视频教程:https://v.qq.com/x/page/t30068qfex5.html (三)下载地址:https://downlo ...
- 转,异常好的sql 基础知识整理
转载自:http://blog.csdn.net/u011001084/article/details/51318434 最近从图书馆借了本介绍SQL的书,打算复习一下基本语法,记录一下笔记,整理一下 ...
- LOJ P10149 凸多边形的划分 题解
Analysis 区间dp+压位高精 dp五分钟,高精两小时 #include<iostream> #include<cstdio> #include<cstring&g ...
- AtCoder Grand Contest 002题解
传送门 \(A\) 咕咕 int main(){ cin>>a>>b; if(b<0)puts(((b-a+1)&1)?"Negative": ...
- 决策单调性优化DP学习笔记
用途 废话,当然是在DP式子满足某些性质的时候来优化复杂度-- 定义 对于\(j\)往大于\(j\)的\(i\)转移,可以表示成一个关于\(i\)的函数\(f_j(i)\),也就是\(dp_i=\ma ...
- kaptcha 配置
问题所在: 这一段配置,不要写在 SpringMVC 文件中,要写在 Spring 配置文件! <!-- kaptcha 验证码 --> <bean id="captcha ...