当前位置:网站首页>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;
}
};
边栏推荐
- 毕业后5年,我终于变成了月薪13000的软件测试工程师
- Sparkrdd case: calculate total score
- Counter完之后,想统计字符串长度大于2的结果
- Interview question catalog collection
- [glib][gstreamer] plug in writing ideas -- inheritance, override and virtual functions
- Dynamic programming-01 backpack, partition, etc. and subset, weight of the last stone
- After the counter is completed, you want to count the results whose string length is greater than 2
- Navicat cannot connect to MySQL
- Yolov3 3D semantic point cloud paper reading
- MySQL dump auto backup database shell script
猜你喜欢

带你区分几种并行

Standing at the digital tuyere, how can tooling enterprises "fly"

SQL操作:WITH表达式及其应用

Summary of new MySQL 8.0 features

Sparkrdd case: calculate total score

【数论】leetcode1010. Pairs of Songs With Total Durations Divisible by 60
![[redis] event driven framework source code analysis (single thread)](/img/72/ae961423832f217324007c81b6f9e5.png)
[redis] event driven framework source code analysis (single thread)

SAP MM 进口采购业务中供应商多送或者少送场景的处理

Dynamic programming-01 backpack, partition, etc. and subset, weight of the last stone

Some introduction and transplantation of lvgl
随机推荐
Conversion between three file handles
How to make your website quickly found by search engines
I just learned a cool 3D pyramid stereoscopic effect. Come and have a look
Judge whether the system CPU is idle
机器学习 Pytorch实现案例 LSTM案例(航班人数预测)
Use gomonkey mock function and method
Sparkrdd case: calculate total score
[glib][gstreamer] plug in writing ideas -- inheritance, override and virtual functions
matplotlib 制作不等间距直方图
类和对象(下)
高分方案纷纷开源,中国“软件杯”遥感赛项第二轮预选赛来了!
【ÑÖÏ模拟赛】花萎(矩阵加速,循环卷积,高斯消元)
SSO and oauth2 solutions
Jpom 简介: 简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件
点云配准--4PCS原理与应用
Precautions for using timestamp type of SQLite3 database
带你区分几种并行
Standing at the digital tuyere, how can tooling enterprises "fly"
Navicat连接不到MySQL
[dailyfresh] course record 3 -- product search related