【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 ...
随机推荐
- [Functional Programming] Rewrite a reducer with functional state ADT
For example we have a feature reducer like this: // selectCard :: String -> Action String export ...
- 自定义简单算法MVC框架
什么是MVC框架 MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写, 它是一种软件设计典范,用一种业务逻辑.数据 ...
- 轻松掌握mongodb
mongodb 是一种非关系型的,面向文档的数据库,也是nosql类的产品 memcache,redis等等 与mysql最大的区别:mongodb 使用javascript语言操作,保存是以json ...
- 063_显示本机 Linux 系统上所有开放的端口列表
#!/bin/bash#从端口列表中观测有没有没用的端口,有的话可以将该端口对应的服务关闭,防止意外的攻击可能性 ss -nutlp |awk '{print $1,$5}' | awk -F&quo ...
- 通过 Ajax 调取后台接口将返回的 json 数据绑定在页面上
第一步: 编写基础的 html 框架内容,并引入 jquery: <!doctype html> <html lang="en"> <head> ...
- 利用 BackgroundService 固定时间间隔执行某动作
继承 BackgroundService 类: 为什么会写这个东西呢?本人在写消息队列的时候思考过一个问题——比如,每5秒从队列里面取一条消息(一条消息里面又包含了1000条数据),要把这1000条数 ...
- P3478 [POI2008]STA-Station
题目描述 The first stage of train system reform (that has been described in the problem Railways of the ...
- 【转】使用 Ansible 实现数据中心自动化管理
长久以来,IT 运维在企业内部一直是个耗人耗力的事情.随着虚拟化的大量应用.私有云.容器的不断普及,数据中心内部的压力愈发增加.传统的自动化工具,往往是面向于数据中心特定的一类对象,例如操作系统.虚拟 ...
- ROSservice 通信方式
操作演示,对 service 通信的理解请看:点击打开链接 1. 使用 rosservice 1.1 rosservice list 假设小乌龟节点仍在运行 rosrun turtlesim tu ...
- maven 聚合工程 > 坑总结
maven聚合工程子项目无法构建:父工程未 install tomcat可以运行,maven 无法编译报错,检查是否添加红色语句: <dependency> <groupId> ...