Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e65d853

Browse files
feat: add solutions to lc problem: No.3141 (doocs#2775)
1 parent a3bb154 commit e65d853

File tree

15 files changed

+483
-69
lines changed

15 files changed

+483
-69
lines changed

‎solution/0100-0199/0165.Compare Version Numbers/README_EN.md‎

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66

77
## Description
88

9-
<p>Given two version numbers,&nbsp;<code>version1</code> and <code>version2</code>, compare them.</p>
9+
<p>Given two <strong>version strings</strong>,&nbsp;<code>version1</code> and <code>version2</code>, compare them. A version string consists of <strong>revisions</strong> separated by dots <code>&#39;.&#39;</code>. The <strong>value of the revision</strong> is its <strong>integer conversion</strong> ignoring leading zeros.</p>
1010

11-
<ul>
12-
</ul>
13-
14-
<p>Version numbers consist of <strong>one or more revisions</strong> joined by a dot&nbsp;<code>&#39;.&#39;</code>. Each revision&nbsp;consists of <strong>digits</strong>&nbsp;and may contain leading <strong>zeros</strong>. Every revision contains <strong>at least one character</strong>. Revisions are <strong>0-indexed from left to right</strong>, with the leftmost revision being revision 0, the next revision being revision 1, and so on. For example&nbsp;<code>2.5.33</code>&nbsp;and&nbsp;<code>0.1</code>&nbsp;are valid version numbers.</p>
15-
16-
<p>To compare version numbers, compare their revisions in <strong>left-to-right order</strong>. Revisions are compared using their&nbsp;<strong>integer value ignoring any leading zeros</strong>. This means that revisions&nbsp;<code>1</code>&nbsp;and&nbsp;<code>001</code>&nbsp;are considered&nbsp;<strong>equal</strong>. If a version number does not specify a revision at an index, then&nbsp;<strong>treat the revision as&nbsp;<code>0</code></strong>. For example, version&nbsp;<code>1.0</code> is less than version&nbsp;<code>1.1</code>&nbsp;because their revision 0s are the same, but their revision 1s are&nbsp;<code>0</code>&nbsp;and&nbsp;<code>1</code>&nbsp;respectively, and&nbsp;<code>0 &lt; 1</code>.</p>
11+
<p>To compare version strings, compare their revision values in <strong>left-to-right order</strong>. If one of the version strings has fewer revisions, treat the missing revision values as <code>0</code>.</p>
1712

1813
<p><em>Return the following:</em></p>
1914

@@ -26,27 +21,39 @@
2621
<p>&nbsp;</p>
2722
<p><strong class="example">Example 1:</strong></p>
2823

29-
<pre>
30-
<strong>Input:</strong> version1 = &quot;1.01&quot;, version2 = &quot;1.001&quot;
31-
<strong>Output:</strong> 0
32-
<strong>Explanation:</strong> Ignoring leading zeroes, both &quot;01&quot; and &quot;001&quot; represent the same integer &quot;1&quot;.
33-
</pre>
24+
<div class="example-block">
25+
<p><strong>Input:</strong> <span class="example-io">version1 = &quot;1.2&quot;, version2 = &quot;1.10&quot;</span></p>
26+
27+
<p><strong>Output:</strong> <span class="example-io">-1</span></p>
28+
29+
<p><strong>Explanation:</strong></p>
30+
31+
<p>version1&#39;s second revision is &quot;2&quot; and version2&#39;s second revision is &quot;10&quot;: 2 &lt; 10, so version1 &lt; version2.</p>
32+
</div>
3433

3534
<p><strong class="example">Example 2:</strong></p>
3635

37-
<pre>
38-
<strong>Input:</strong> version1 = &quot;1.0&quot;, version2 = &quot;1.0.0&quot;
39-
<strong>Output:</strong> 0
40-
<strong>Explanation:</strong> version1 does not specify revision 2, which means it is treated as &quot;0&quot;.
41-
</pre>
36+
<div class="example-block">
37+
<p><strong>Input:</strong> <span class="example-io">version1 = &quot;1.01&quot;, version2 = &quot;1.001&quot;</span></p>
38+
39+
<p><strong>Output:</strong> <span class="example-io">0</span></p>
40+
41+
<p><strong>Explanation:</strong></p>
42+
43+
<p>Ignoring leading zeroes, both &quot;01&quot; and &quot;001&quot; represent the same integer &quot;1&quot;.</p>
44+
</div>
4245

4346
<p><strong class="example">Example 3:</strong></p>
4447

45-
<pre>
46-
<strong>Input:</strong> version1 = &quot;0.1&quot;, version2 = &quot;1.1&quot;
47-
<strong>Output:</strong> -1
48-
<strong>Explanation:</strong> version1&#39;s revision 0 is &quot;0&quot;, while version2&#39;s revision 0 is &quot;1&quot;. 0 &lt; 1, so version1 &lt; version2.
49-
</pre>
48+
<div class="example-block">
49+
<p><strong>Input:</strong> <span class="example-io">version1 = &quot;1.0&quot;, version2 = &quot;1.0.0.0&quot;</span></p>
50+
51+
<p><strong>Output:</strong> <span class="example-io">0</span></p>
52+
53+
<p><strong>Explanation:</strong></p>
54+
55+
<p>version1 has less revisions, which means every missing revision are treated as &quot;0&quot;.</p>
56+
</div>
5057

5158
<p>&nbsp;</p>
5259
<p><strong>Constraints:</strong></p>

‎solution/0800-0899/0857.Minimum Cost to Hire K Workers/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<p>有 <code>n</code>&nbsp;名工人。&nbsp;给定两个数组&nbsp;<code>quality</code>&nbsp;&nbsp;<code>wage</code>&nbsp;,其中,<code>quality[i]</code>&nbsp;表示第&nbsp;<code>i</code>&nbsp;名工人的工作质量,其最低期望工资为&nbsp;<code>wage[i]</code>&nbsp;。</p>
1212

13-
<p>现在我们想雇佣&nbsp;<code>k</code>&nbsp;名工人组成一个<em>工资组。</em>在雇佣&nbsp;一组 <code>k</code>&nbsp;名工人时,我们必须按照下述规则向他们支付工资:</p>
13+
<p>现在我们想雇佣&nbsp;<code>k</code>&nbsp;名工人组成一个&nbsp;<strong>工资组</strong><em>。</em>在雇佣&nbsp;一组 <code>k</code>&nbsp;名工人时,我们必须按照下述规则向他们支付工资:</p>
1414

1515
<ol>
1616
<li>对工资组中的每名工人,应当按其工作质量与同组其他工人的工作质量的比例来支付工资。</li>
@@ -24,14 +24,14 @@
2424
<ol>
2525
</ol>
2626

27-
<p><strong>示例 1:</strong></p>
27+
<p><strongclass="example">示例 1:</strong></p>
2828

2929
<pre>
3030
<strong>输入: </strong>quality = [10,20,5], wage = [70,50,30], k = 2
3131
<strong>输出: </strong>105.00000
3232
<strong>解释:</strong> 我们向 0 号工人支付 70,向 2 号工人支付 35。</pre>
3333

34-
<p><strong>示例 2:</strong></p>
34+
<p><strongclass="example">示例 2:</strong></p>
3535

3636
<pre>
3737
<strong>输入: </strong>quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3

‎solution/0800-0899/0857.Minimum Cost to Hire K Workers/README_EN.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
<p>There are <code>n</code> workers. You are given two integer arrays <code>quality</code> and <code>wage</code> where <code>quality[i]</code> is the quality of the <code>i<sup>th</sup></code> worker and <code>wage[i]</code> is the minimum wage expectation for the <code>i<sup>th</sup></code> worker.</p>
1010

11-
<p>We want to hire exactly <code>k</code> workers to form a paid group. To hire a group of <code>k</code> workers, we must pay them according to the following rules:</p>
11+
<p>We want to hire exactly <code>k</code> workers to form a <strong>paid group</strong>. To hire a group of <code>k</code> workers, we must pay them according to the following rules:</p>
1212

1313
<ol>
14-
<li>Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.</li>
1514
<li>Every worker in the paid group must be paid at least their minimum wage expectation.</li>
15+
<li>In the group, each worker&#39;s pay must be directly proportional to their quality. This means if a worker&rsquo;s quality is double that of another worker in the group, then they must be paid twice as much as the other worker.</li>
1616
</ol>
1717

1818
<p>Given the integer <code>k</code>, return <em>the least amount of money needed to form a paid group satisfying the above conditions</em>. Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted.</p>

‎solution/1100-1199/1112.Highest Grade For Each Student/README.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ grade 不会为 NULL。</pre>
2525

2626
<p>编写解决方案,找出每位学生获得的最高成绩和它所对应的科目,若科目成绩并列,取&nbsp;<code>course_id</code>&nbsp;最小的一门。查询结果需按&nbsp;<code>student_id</code>&nbsp;增序进行排序。</p>
2727

28-
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
29-
3028
<p>查询结果格式如下所示。</p>
3129

3230
<p>&nbsp;</p>

‎solution/2000-2099/2077.Paths in Maze That Lead to Same Room/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<!-- 这里写题目描述 -->
1010

11-
<p>迷宫由 <code>n</code> 个从 <code>1</code> 到 <code>n</code> 的房间组成,有些房间由走廊连接。给定一个二维整数数组 <code>corridors</code>,其中 <code>corridors[i] = [room1<sub>i</sub>, room2<sub>i</sub>]</code>&nbsp;表示有一条走廊连接 <code>room1<sub>i</sub></code> 和<code>room2<sub>i</sub></code>,允许迷宫中的一个人从 <code>room1<sub>i</sub></code> 到 <code>room1<sub>i</sub></code> ,<strong>反之亦然</strong>。</p>
11+
<p>迷宫由 <code>n</code> 个从 <code>1</code> 到 <code>n</code> 的房间组成,有些房间由走廊连接。给定一个二维整数数组 <code>corridors</code>,其中 <code>corridors[i] = [room1<sub>i</sub>, room2<sub>i</sub>]</code>&nbsp;表示有一条走廊连接 <code>room1<sub>i</sub></code> 和<code>room2<sub>i</sub></code>,允许迷宫中的一个人从 <code>room1<sub>i</sub></code> 到 <code>room2<sub>i</sub></code> ,<strong>反之亦然</strong>。</p>
1212

1313
<p>迷宫的设计者想知道迷宫有多让人困惑。迷宫的&nbsp;<strong>混乱分数&nbsp;</strong>是&nbsp;<strong>长度为 3</strong> 的不同的环的数量。</p>
1414

‎solution/2100-2199/2105.Watering Plants II/README.md‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414

1515
<ul>
1616
<li>&nbsp;Alice 按 <strong>从左到右</strong> 的顺序给植物浇水,从植物 <code>0</code> 开始。Bob 按 <strong>从右到左</strong> 的顺序给植物浇水,从植物 <code>n - 1</code> 开始。他们 <strong>同时</strong> 给植物浇水。</li>
17-
<li>如果没有足够的水 <strong>完全</strong> 浇灌下一株植物,他 / 她会立即重新灌满浇水罐。</li>
18-
<li>不管植物需要多少水,浇水所耗费的时间都是一样的。</li>
19-
<li><strong>不能</strong> 提前重新灌满水罐。</li>
20-
<li>每株植物都可以由 Alice 或者 Bob 来浇水。</li>
21-
<li>如果 Alice 和 Bob 到达同一株植物,那么当前水罐中水更多的人会给这株植物浇水。如果他俩水量相同,那么 Alice 会给这株植物浇水。</li>
17+
<li>无论需要多少水,为每株植物浇水所需的时间都是相同的。</li>
18+
<li>如果 Alice/Bob 水罐中的水足以 <strong>完全</strong> 灌溉植物,他们 <strong>必须</strong> 给植物浇水。否则,他们 <strong>首先</strong>(立即)重新装满罐子,然后给植物浇水。</li>
19+
<li>如果 Alice 和 Bob 到达同一株植物,那么当前水罐中水 <strong>更多</strong> 的人会给这株植物浇水。如果他俩水量相同,那么 Alice 会给这株植物浇水。</li>
2220
</ul>
2321

2422
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>plants</code> ,数组由 <code>n</code> 个整数组成。其中,<code>plants[i]</code> 为第 <code>i</code> 株植物需要的水量。另有两个整数 <code>capacityA</code> 和&nbsp;<code>capacityB</code> 分别表示 Alice 和 Bob 水罐的容量。返回两人浇灌所有植物过程中重新灌满水罐的 <strong>次数</strong> 。</p>

‎solution/2500-2599/2563.Count the Number of Fair Pairs/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<pre>
3333
<b>输入:</b>nums = [1,7,9,2,5], lower = 11, upper = 11
3434
<b>输出:</b>1
35-
<b>解释:</b>只有单个公平数对:(2,9) 。
35+
<b>解释:</b>只有单个公平数对:(2,3) 。
3636
</pre>
3737

3838
<p>&nbsp;</p>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /