1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 11:21:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part2

This commit is contained in:
2022-03-27 20:38:29 +08:00
parent 5a4fa6db12
commit 0fc7f4b734
1617 changed files with 134637 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
<p>存在一种仅支持 4 种操作和 1 个变量 <code>X</code> 的编程语言:</p>
<ul>
<li><code>++X</code><code>X++</code> 使变量 <code>X</code> 的值 <strong></strong> <code>1</code></li>
<li><code>--X</code><code>X--</code> 使变量 <code>X</code> 的值 <strong></strong> <code>1</code></li>
</ul>
<p>最初,<code>X</code> 的值是 <code>0</code></p>
<p>给你一个字符串数组 <code>operations</code> ,这是由操作组成的一个列表,返回执行所有操作后,<em> </em><code>X</code><strong>最终值</strong></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>operations = ["--X","X++","X++"]
<strong>输出:</strong>1
<strong>解释:</strong>操作按下述步骤执行:
最初X = 0
--XX 减 1 X = 0 - 1 = -1
X++X 加 1 X = -1 + 1 = 0
X++X 加 1 X = 0 + 1 = 1
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>operations = ["++X","++X","X++"]
<strong>输出:</strong>3
<strong>解释:</strong>操作按下述步骤执行:
最初X = 0
++XX 加 1 X = 0 + 1 = 1
++XX 加 1 X = 1 + 1 = 2
X++X 加 1 X = 2 + 1 = 3
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>operations = ["X++","++X","--X","X--"]
<strong>输出:</strong>0
<strong>解释:</strong>操作按下述步骤执行:
最初X = 0
X++X 加 1 X = 0 + 1 = 1
++XX 加 1 X = 1 + 1 = 2
--XX 减 1 X = 2 - 1 = 1
X--X 减 1 X = 1 - 1 = 0
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= operations.length &lt;= 100</code></li>
<li><code>operations[i]</code> 将会是 <code>"++X"</code><code>"X++"</code><code>"--X"</code><code>"X--"</code></li>
</ul>