1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/查询无效交易 [invalid-transactions].html

46 lines
2.3 KiB
HTML
Raw Normal View History

2022-03-27 20:37:52 +08:00
<p>如果出现下述两种情况,交易 <strong>可能无效</strong></p>
<ul>
<li>交易金额超过<meta charset="UTF-8" />&nbsp;<code>$1000</code></li>
<li>或者,它和&nbsp;<strong>另一个城市</strong>&nbsp;<strong>同名</strong> 的另一笔交易相隔不超过 <code>60</code> 分钟(包含 60 分钟整)</li>
</ul>
<p>给定字符串数组交易清单<meta charset="UTF-8" />&nbsp;<code>transaction</code>&nbsp;。每个交易字符串&nbsp;<code>transactions[i]</code>&nbsp;由一些用逗号分隔的值组成,这些值分别表示交易的名称,时间(以分钟计),金额以及城市。</p>
<p>返回&nbsp;<code>transactions</code>,返回可能无效的交易列表。你可以按 <strong>任何顺序</strong> 返回答案。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>transactions = ["alice,20,800,mtv","alice,50,100,beijing"]
<strong>输出:</strong>["alice,20,800,mtv","alice,50,100,beijing"]
<strong>解释:</strong>第一笔交易是无效的,因为第二笔交易和它间隔不超过 60 分钟、名称相同且发生在不同的城市。同样,第二笔交易也是无效的。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>transactions = ["alice,20,800,mtv","alice,50,1200,mtv"]
<strong>输出:</strong>["alice,50,1200,mtv"]
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>transactions = ["alice,20,800,mtv","bob,50,1200,mtv"]
<strong>输出:</strong>["bob,50,1200,mtv"]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>transactions.length &lt;= 1000</code></li>
<li>每笔交易&nbsp;<code>transactions[i]</code>&nbsp;&nbsp;<code>"{name},{time},{amount},{city}"</code>&nbsp;的格式进行记录</li>
<li>每个交易名称&nbsp;<code>{name}</code>&nbsp;和城市&nbsp;<code>{city}</code>&nbsp;都由小写英文字母组成,长度在&nbsp;<code>1</code>&nbsp;&nbsp;<code>10</code>&nbsp;之间</li>
<li>每个交易时间&nbsp;<code>{time}</code>&nbsp;由一些数字组成,表示一个&nbsp;<code>0</code>&nbsp;&nbsp;<code>1000</code>&nbsp;之间的整数</li>
<li>每笔交易金额&nbsp;<code>{amount}</code>&nbsp;由一些数字组成,表示一个&nbsp;<code>0</code>&nbsp;<code>2000</code>&nbsp;之间的整数</li>
</ul>