当前位置:网站首页>2011. variable value after operation
2011. variable value after operation
2022-06-22 01:34:00 【Drag is me】
leetcode Force button to brush questions and punch in
subject :2011. Variable value after operation
describe : There is one that only supports 4 Kind of operation and 1 A variable X Programming language :
++X and X++ Make variable X Value Add 1
–X and X-- Make variable X Value reduce 1
first ,X The value of is 0
Here's an array of strings operations , This is a list of operations , Return to after performing all operations , X Of In the end .
Their thinking
1、 Program in the order required by the topic ;
Source code ##
class Solution {
public:
int finalValueAfterOperations(vector<string>& operations) {
int x = 0;
int len = operations.size();
for (int i = 0; i < len; ++i) {
for (int j = 0; j < 3; ++j) {
if (operations[i][j] == '-') {
x--;
break;
}
if (operations[i][j] == '+') {
x++;
break;
}
}
}
return x;
}
};
边栏推荐
- 4g/wifi energy consumption metering socket - monitoring voltage, current and power
- Navicat连接不到MySQL
- Unlovable STL
- Navicat cannot connect to MySQL
- Promise me not to use if (obj! = null) to judge empty
- Mysql database high version low version
- PM2 learning
- 刚学了一个炫酷3D三棱锥立体特效,快来看看
- MySQL collation
- matplotlib 制作不等间距直方图
猜你喜欢

記錄webscraper的使用過程

【NOI模拟赛】区间距离(分块,卷积)

Idea prompt duplicated code fragment (15 lines long)

Jpom 简介: 简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件

MySQL 8.0 新特性梳理汇总

记录webscraper的使用过程

How to remove duplication in left join from a simple example

SQL operation: with expression and its application

SSO and oauth2 solutions

类和对象(下)
随机推荐
Yolov3 3D semantic point cloud paper reading
Shardingsphere-proxy-5.0.0 implementation of distributed hash modulo fragmentation (4)
同济、阿里获CVPR最佳学生论文,李飞飞获黄煦涛奖,近6000人线下参会
Cancellation meeting and automatic refund processing of message queue
Idea prompt 'optional Get() 'without' ispresent() 'check error.
What does container cloud mean? What is the difference with fortress machine?
Classes and objects (Part 2)
[ÑÖÏ Simulation Competition] fading (matrix acceleration, cyclic convolution, Gauss elimination)
The problem of connecting to the server with MySQL client under cygwin
Processing of the scenario of more or less delivery by suppliers in SAP mm import purchase business
Documenter l'utilisation de webcraper
The use of PowerShell functions in mathematical expressions
Precautions for using timestamp type of SQLite3 database
[solution] Ming Chu Liang Zao video edge computing gateway solution
Virtual variables and formatting characters in debugging
Difference between MSVC and GCC (under collection)
php-admin部署-解决全部错误
动态规划-01背包,分割等和子集,最后一块石头的重量
点云配准--4PCS原理与应用
Use of listctl virtual mode under wince