Skip to content

Commit 75eedb3

Browse files
authored
feat: update lc problems (#3046)
1 parent fb68f57 commit 75eedb3

File tree

7 files changed

+73
-45
lines changed

7 files changed

+73
-45
lines changed

solution/0200-0299/0249.Group Shifted Strings/README_EN.md

+21-11
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,38 @@ tags:
1818

1919
<!-- description:start -->
2020

21-
<p>We can shift a string by shifting each of its letters to its successive letter.</p>
21+
<p>Perform the following shift operations on a string:</p>
2222

2323
<ul>
24-
<li>For example, <code>&quot;abc&quot;</code> can be shifted to be <code>&quot;bcd&quot;</code>.</li>
24+
<li><strong>Right shift</strong>: Replace every letter with the <strong>successive</strong> letter of the English alphabet, where &#39;z&#39; is replaced by &#39;a&#39;. For example, <code>&quot;abc&quot;</code> can be right-shifted to <code>&quot;bcd&quot; </code>or <code>&quot;xyz&quot;</code> can be right-shifted to <code>&quot;yza&quot;</code>.</li>
25+
<li><strong>Left shift</strong>: Replace every letter with the <strong>preceding</strong> letter of the English alphabet, where &#39;a&#39; is replaced by &#39;z&#39;. For example, <code>&quot;bcd&quot;</code> can be left-shifted to <code>&quot;abc&quot;<font face="Times New Roman"> or </font></code><code>&quot;yza&quot;</code> can be left-shifted to <code>&quot;xyz&quot;</code>.</li>
2526
</ul>
2627

27-
<p>We can keep shifting the string to form a sequence.</p>
28+
<p>We can keep shifting the string in both directions to form an <strong>endless</strong> <strong>shifting sequence</strong>.</p>
2829

2930
<ul>
30-
<li>For example, we can keep shifting <code>&quot;abc&quot;</code> to form the sequence: <code>&quot;abc&quot; -&gt; &quot;bcd&quot; -&gt; ... -&gt; &quot;xyz&quot;</code>.</li>
31+
<li>For example, shift <code>&quot;abc&quot;</code> to form the sequence: <code>... &lt;-&gt; &quot;abc&quot; &lt;-&gt; &quot;bcd&quot; &lt;-&gt; ... &lt;-&gt; &quot;xyz&quot; &lt;-&gt; &quot;yza&quot; &lt;-&gt; ...</code>.<code> &lt;-&gt; &quot;zab&quot; &lt;-&gt; &quot;abc&quot; &lt;-&gt; ...</code></li>
3132
</ul>
3233

33-
<p>Given an array of strings <code>strings</code>, group all <code>strings[i]</code> that belong to the same shifting sequence. You may return the answer in <strong>any order</strong>.</p>
34+
<p>You are given an array of strings <code>strings</code>, group together all <code>strings[i]</code> that belong to the same shifting sequence. You may return the answer in <strong>any order</strong>.</p>
3435

3536
<p>&nbsp;</p>
3637
<p><strong class="example">Example 1:</strong></p>
37-
<pre><strong>Input:</strong> strings = ["abc","bcd","acef","xyz","az","ba","a","z"]
38-
<strong>Output:</strong> [["acef"],["a","z"],["abc","bcd","xyz"],["az","ba"]]
39-
</pre><p><strong class="example">Example 2:</strong></p>
40-
<pre><strong>Input:</strong> strings = ["a"]
41-
<strong>Output:</strong> [["a"]]
42-
</pre>
38+
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">strings = [&quot;abc&quot;,&quot;bcd&quot;,&quot;acef&quot;,&quot;xyz&quot;,&quot;az&quot;,&quot;ba&quot;,&quot;a&quot;,&quot;z&quot;]</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">[[&quot;acef&quot;],[&quot;a&quot;,&quot;z&quot;],[&quot;abc&quot;,&quot;bcd&quot;,&quot;xyz&quot;],[&quot;az&quot;,&quot;ba&quot;]]</span></p>
43+
</div>
44+
45+
<p><strong class="example">Example 2:</strong></p>
46+
47+
<div class="example-block">
48+
<p><strong>Input:</strong> <span class="example-io">strings = [&quot;a&quot;]</span></p>
49+
50+
<p><strong>Output:</strong> <span class="example-io">[[&quot;a&quot;]]</span></p>
51+
</div>
52+
4353
<p>&nbsp;</p>
4454
<p><strong>Constraints:</strong></p>
4555

solution/2500-2599/2595.Number of Even and Odd Bits/README_EN.md

+27-17
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,42 @@ tags:
2020

2121
<p>You are given a <strong>positive</strong> integer <code>n</code>.</p>
2222

23-
<p>Let <code>even</code> denote the number of even indices in the binary representation of <code>n</code> (<strong>0-indexed</strong>) with value <code>1</code>.</p>
23+
<p>Let <code>even</code> denote the number of even indices in the binary representation of <code>n</code> with value 1.</p>
2424

25-
<p>Let <code>odd</code> denote the number of odd indices in the binary representation of <code>n</code> (<strong>0-indexed</strong>) with value <code>1</code>.</p>
25+
<p>Let <code>odd</code> denote the number of odd indices in the binary representation of <code>n</code> with value 1.</p>
2626

27-
<p>Return <em>an integer array </em><code>answer</code><em> where </em><code>answer = [even, odd]</code>.</p>
27+
<p>Note that bits are indexed from <strong>right to left</strong> in the binary representation of a number.</p>
28+
29+
<p>Return the array <code>[even, odd]</code>.</p>
2830

2931
<p>&nbsp;</p>
3032
<p><strong class="example">Example 1:</strong></p>
3133

32-
<pre>
33-
<strong>Input:</strong> n = 17
34-
<strong>Output:</strong> [2,0]
35-
<strong>Explanation:</strong> The binary representation of 17 is 10001.
36-
It contains 1 on the 0<sup>th</sup> and 4<sup>th</sup> indices.
37-
There are 2 even and 0 odd indices.
38-
</pre>
34+
<div class="example-block">
35+
<p><strong>Input:</strong> <span class="example-io">n = 50</span></p>
36+
37+
<p><strong>Output:</strong> <span class="example-io">[1,2]</span></p>
38+
39+
<p><strong>Explanation:</strong></p>
40+
41+
<p>The binary representation of 50 is <code>110010</code>.</p>
42+
43+
<p>It contains 1 on indices 1, 4, and 5.</p>
44+
</div>
3945

4046
<p><strong class="example">Example 2:</strong></p>
4147

42-
<pre>
43-
<strong>Input:</strong> n = 2
44-
<strong>Output:</strong> [0,1]
45-
<strong>Explanation:</strong> The binary representation of 2 is 10.
46-
It contains 1 on the 1<sup>st</sup> index.
47-
There are 0 even and 1 odd indices.
48-
</pre>
48+
<div class="example-block">
49+
<p><strong>Input:</strong> <span class="example-io">n = 2</span></p>
50+
51+
<p><strong>Output:</strong> <span class="example-io">[0,1]</span></p>
52+
53+
<p><strong>Explanation:</strong></p>
54+
55+
<p>The binary representation of 2 is <code>10</code>.</p>
56+
57+
<p>It contains 1 only on index 1.</p>
58+
</div>
4959

5060
<p>&nbsp;</p>
5161
<p><strong>Constraints:</strong></p>

solution/2600-2699/2644.Find the Maximum Divisibility Score/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tags:
2222

2323
<p>The <strong>divisibility score</strong> of <code>divisors[i]</code> is the number of indices <code>j</code> such that <code>nums[j]</code> is divisible by <code>divisors[i]</code>.</p>
2424

25-
<p>Return the integer <code>divisors[i]</code> with the <strong>maximum</strong> divisibility score. If multiple numbers have the maximum score, return the smallest one.</p>
25+
<p>Return the integer <code>divisors[i]</code> with the <strong>maximum</strong> divisibility score. If multiple integers have the maximum score, return the smallest one.</p>
2626

2727
<p>&nbsp;</p>
2828
<p><strong class="example">Example 1:</strong></p>
@@ -58,7 +58,7 @@ tags:
5858

5959
<p>The divisibility score of <code>divisors[1]</code> is 1 since only <code>nums[0]</code> is divisible by 2.</p>
6060

61-
<p>The divisibility score of <code>divisors[2]</code> is 3 since <code>nums[2]</code> , <code>nums[3]</code> and <code>nums[4]</code> are divisible by 3.</p>
61+
<p>The divisibility score of <code>divisors[2]</code> is 3 since <code>nums[2]</code>, <code>nums[3]</code> and <code>nums[4]</code> are divisible by 3.</p>
6262
</div>
6363

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

solution/2800-2899/2862.Maximum Element-Sum of a Complete Subset of Indices/README.md

+20-12
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,29 @@ tags:
2626

2727
<p>&nbsp;</p>
2828

29-
<p><strong>示例 1:</strong></p>
29+
<p><strong class="example">示例 1:</strong></p>
3030

31-
<pre>
32-
<strong>输入:</strong>nums = [8,7,3,5,7,2,4,9]
33-
<strong>输出:</strong>16
34-
<strong>解释:</strong>我们选择了下标 2 和 8 的元素,并且 2 * 8 是一个完全平方数。
35-
</pre>
31+
<div class="example-block">
32+
<p><strong>输入:</strong><span class="example-io">nums = [8,7,3,5,7,2,4,9]</span></p>
3633

37-
<p><strong>示例 2:</strong></p>
34+
<p><strong>输出:</strong><span class="example-io">16</span></p>
3835

39-
<pre>
40-
<strong>输入:</strong>nums = [8,10,3,8,1,13,7,9,4]
41-
<strong>输出:</strong>20
42-
<strong>解释:</strong>我们选择了下标 1,4 和 9 的元素。1 * 4,1 * 9,4 * 9 都是完全平方数。
43-
</pre>
36+
<p><strong>解释:</strong></p>
37+
38+
<p>我们选择下标为 2 和 8 的元素,并且&nbsp;<code>1 * 4</code>&nbsp;是一个完全平方数。</p>
39+
</div>
40+
41+
<p><strong class="example">示例 2:</strong></p>
42+
43+
<div class="example-block">
44+
<p><span class="example-io"><b>输入:</b>nums = [8,10,3,8,1,13,7,9,4]</span></p>
45+
46+
<p><span class="example-io"><b>输出:</b>20</span></p>
47+
48+
<p><strong>解释:</strong></p>
49+
50+
<p>我们选择下标为 1, 4, 9 的元素。<code>1 * 4</code>, <code>1 * 9</code>, <code>4 * 9</code>&nbsp;是完全平方数。</p>
51+
</div>
4452

4553
<p>&nbsp;</p>
4654

solution/2800-2899/2862.Maximum Element-Sum of a Complete Subset of Indices/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tags:
3434

3535
<p><strong>Explanation:</strong></p>
3636

37-
<p>We select elements at indices 1 and 4 and <code>1 * 4</code> is a perfect square.</p>
37+
<p>We select elements at indices 2 and 8 and <code>1 * 4</code> is a perfect square.</p>
3838
</div>
3939

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

solution/3100-3199/3173.Bitwise OR of Adjacent Elements/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3100-3199/3173.Bi
5959

6060
我们遍历数组的前 $n - 1$ 个元素,对于每个元素,计算它和它的下一个元素的按位或值,将结果存入答案数组中。
6161

62-
时间复杂度 $O(n)$,其中 $n$ 是数组的长度。空间复杂度 $O(1)$。
62+
时间复杂度 $O(n)$,其中 $n$ 是数组的长度。忽略答案数组的空间消耗,空间复杂度 $O(1)$。
6363

6464
<!-- tabs:start -->
6565

solution/3100-3199/3173.Bitwise OR of Adjacent Elements/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3100-3199/3173.Bi
5959

6060
We iterate through the first $n - 1$ elements of the array. For each element, we calculate the bitwise OR value of it and its next element, and store the result in the answer array.
6161

62-
The time complexity is $O(n)$, where $n$ is the length of the array. The space complexity is $O(1)$.
62+
The time complexity is $O(n)$, where $n$ is the length of the array. Ignoring the space consumption of the answer array, the space complexity is $O(1)$.
6363

6464
<!-- tabs:start -->
6565

0 commit comments

Comments
 (0)