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 7974e9d

Browse files
author
Shuo
authored
Merge pull request #528 from openset/develop
Update: description
2 parents fbe20b9 + a868cf8 commit 7974e9d

File tree

7 files changed

+98
-81
lines changed

7 files changed

+98
-81
lines changed

‎problems/length-of-last-word/README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111

1212
## 58. Length of Last Word (Easy)
1313

14-
<p>Given a string <i>s</i> consists of upper/lower-case alphabets and empty space characters <code>' '</code>, return the length of last word in the string.</p>
14+
<p>Given a string <i>s</i> consists of upper/lower-case alphabets and empty space characters <code>&#39;&#39;</code>, return the length of last word in the string.</p>
1515

1616
<p>If the last word does not exist, return 0.</p>
1717

1818
<p><b>Note:</b> A word is defined as a character sequence consists of non-space characters only.</p>
1919

20-
<p><b>Example:</b>
20+
<p><b>Example:</b></p>
21+
2122
<pre>
22-
<b>Input:</b> "Hello World"
23+
<b>Input:</b> &quot;Hello World&quot;
2324
<b>Output:</b> 5
2425
</pre>
25-
</p>
26+
27+
<p>&nbsp;</p>
2628

2729
### Related Topics
2830
[[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]

‎problems/maximum-sum-of-3-non-overlapping-subarrays/README.md‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,32 @@
1111

1212
## 689. Maximum Sum of 3 Non-Overlapping Subarrays (Hard)
1313

14-
<p>
15-
In a given array <code>nums</code> of positive integers, find three non-overlapping subarrays with maximum sum.
16-
</p>
17-
<p>
18-
Each subarray will be of size <code>k</code>, and we want to maximize the sum of all <code>3*k</code> entries.
19-
</p>
20-
<p>
21-
Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answers, return the lexicographically smallest one.
22-
</p>
23-
<p><b>Example:</b><br />
14+
<p>In a given array <code>nums</code> of positive integers, find three non-overlapping subarrays with maximum sum.</p>
15+
16+
<p>Each subarray will be of size <code>k</code>, and we want to maximize the sum of all <code>3*k</code> entries.</p>
17+
18+
<p>Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answers, return the lexicographically smallest one.</p>
19+
20+
<p><b>Example:</b></p>
21+
2422
<pre>
2523
<b>Input:</b> [1,2,1,2,6,7,5,1], 2
2624
<b>Output:</b> [0, 3, 5]
2725
<b>Explanation:</b> Subarrays [1, 2], [2, 6], [7, 5] correspond to the starting indices [0, 3, 5].
2826
We could have also taken [2, 1], but an answer of [1, 3, 5] would be lexicographically larger.
2927
</pre>
30-
</p>
3128

32-
<p><b>Note:</b><br />
33-
<li><code>nums.length</code> will be between 1 and 20000.</li>
34-
<li><code>nums[i]</code> will be between 1 and 65535.</li>
35-
<li><code>k</code> will be between 1 and floor(nums.length / 3).</li>
36-
</p>
29+
<p>&nbsp;</p>
30+
31+
<p><b>Note:</b></p>
32+
33+
<ul>
34+
<li><code>nums.length</code> will be between 1 and 20000.</li>
35+
<li><code>nums[i]</code> will be between 1 and 65535.</li>
36+
<li><code>k</code> will be between 1 and floor(nums.length / 3).</li>
37+
</ul>
38+
39+
<p>&nbsp;</p>
3740

3841
### Related Topics
3942
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]

‎problems/minimize-malware-spread/README.md‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,25 @@
2626
<ol>
2727
</ol>
2828

29-
<div>
3029
<p><strong>Example 1:</strong></p>
3130

3231
<pre>
33-
<strong>Input: </strong>graph = <spanid="example-input-1-1">[[1,1,0],[1,1,0],[0,0,1]]</span>, initial = <spanid="example-input-1-2">[0,1]</span>
34-
<strong>Output: </strong><spanid="example-output-1">0</span>
32+
<strong>Input: </strong>graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]
33+
<strong>Output: </strong>0
3534
</pre>
3635

37-
<div>
3836
<p><strong>Example 2:</strong></p>
3937

4038
<pre>
41-
<strong>Input: </strong>graph = <spanid="example-input-2-1">[[1,0,0],[0,1,0],[0,0,1]]</span>, initial = <spanid="example-input-2-2">[0,2]</span>
42-
<strong>Output: </strong><spanid="example-output-2">0</span>
39+
<strong>Input: </strong>graph = [[1,0,0],[0,1,0],[0,0,1]], initial = [0,2]
40+
<strong>Output: </strong>0
4341
</pre>
4442

45-
<div>
4643
<p><strong>Example 3:</strong></p>
4744

4845
<pre>
49-
<strong>Input: </strong>graph = <spanid="example-input-3-1">[[1,1,1],[1,1,1],[1,1,1]]</span>, initial = <spanid="example-input-3-2">[1,2]</span>
50-
<strong>Output: </strong><spanid="example-output-3">1</span>
46+
<strong>Input: </strong>graph = [[1,1,1],[1,1,1],[1,1,1]], initial = [1,2]
47+
<strong>Output: </strong>1
5148
</pre>
5249

5350
<p>&nbsp;</p>
@@ -61,9 +58,6 @@
6158
<li><code>1 &lt;= initial.length &lt; graph.length</code></li>
6259
<li><code>0 &lt;= initial[i] &lt; graph.length</code></li>
6360
</ol>
64-
</div>
65-
</div>
66-
</div>
6761

6862
### Related Topics
6963
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]

‎problems/ones-and-zeroes/README.md‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,41 @@
1212
## 474. Ones and Zeroes (Medium)
1313

1414
<p>In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.</p>
15+
1516
<p>For now, suppose you are a dominator of <b>m</b> <code>0s</code> and <b>n</b> <code>1s</code> respectively. On the other hand, there is an array with strings consisting of only <code>0s</code> and <code>1s</code>.</p>
1617

17-
<p>
18-
Now your task is to find the maximum number of strings that you can form with given <b>m</b> <code>0s</code> and <b>n</b> <code>1s</code>. Each <code>0</code> and <code>1</code> can be used at most <b>once</b>.
19-
</p>
18+
<p>Now your task is to find the maximum number of strings that you can form with given <b>m</b> <code>0s</code> and <b>n</b> <code>1s</code>. Each <code>0</code> and <code>1</code> can be used at most <b>once</b>.</p>
2019

20+
<p><b>Note:</b></p>
2121

22-
<p><b>Note:</b><br>
2322
<ol>
24-
<li>The given numbers of <code>0s</code> and <code>1s</code> will both not exceed <code>100</code></li>
25-
<li>The size of given string array won't exceed <code>600</code>.</li>
23+
<li>The given numbers of <code>0s</code> and <code>1s</code> will both not exceed <code>100</code></li>
24+
<li>The size of given string array won&#39;t exceed <code>600</code>.</li>
2625
</ol>
27-
</p>
2826

29-
<p><b>Example 1:</b><br />
27+
<p>&nbsp;</p>
28+
29+
<p><b>Example 1:</b></p>
30+
3031
<pre>
31-
<b>Input:</b> Array = {"10", "0001", "111001", "1", "0"}, m = 5, n = 3
32+
<b>Input:</b> Array = {&quot;10&quot;, &quot;0001&quot;, &quot;111001&quot;, &quot;1&quot;, &quot;0&quot;}, m = 5, n = 3
3233
<b>Output:</b> 4
3334

34-
<b>Explanation:</b> This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are "10,"0001","1","0"
35+
<b>Explanation:</b> This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are &ldquo;10,&rdquo;0001&rdquo;,&rdquo;1&rdquo;,&rdquo;0&rdquo;
3536
</pre>
36-
</p>
3737

38-
<p><b>Example 2:</b><br />
38+
<p>&nbsp;</p>
39+
40+
<p><b>Example 2:</b></p>
41+
3942
<pre>
40-
<b>Input:</b> Array = {"10", "0", "1"}, m = 1, n = 1
43+
<b>Input:</b> Array = {&quot;10&quot;, &quot;0&quot;, &quot;1&quot;}, m = 1, n = 1
4144
<b>Output:</b> 2
4245

43-
<b>Explanation:</b> You could form "10", but then you'd have nothing left. Better form "0" and "1".
46+
<b>Explanation:</b> You could form &quot;10&quot;, but then you&#39;d have nothing left. Better form &quot;0&quot; and &quot;1&quot;.
4447
</pre>
45-
</p>
48+
49+
<p>&nbsp;</p>
4650

4751
### Related Topics
4852
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]

‎problems/pyramid-transition-matrix/README.md‎

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,52 @@
1111

1212
## 756. Pyramid Transition Matrix (Medium)
1313

14-
<p>
15-
We are stacking blocks to form a pyramid. Each block has a color which is a one letter string, like `'Z'`.
16-
</p><p>
17-
For every block of color `C` we place not in the bottom row, we are placing it on top of a left block of color `A` and right block of color `B`. We are allowed to place the block there only if `(A, B, C)` is an allowed triple.
18-
</p><p>
19-
We start with a bottom row of <code>bottom</code>, represented as a single string. We also start with a list of allowed triples <code>allowed</code>. Each allowed triple is represented as a string of length 3.
20-
</p><p>
21-
Return true if we can build the pyramid all the way to the top, otherwise false.
22-
</p>
23-
24-
<p><b>Example 1:</b><br />
14+
<p>We are stacking blocks to form a pyramid. Each block has a color which is a one letter string.</p>
15+
16+
<p>We are allowed to place any color block <code>C</code> on top of two adjacent blocks of colors <code>A</code> and <code>B</code>, if and only if <code>ABC</code> is an allowed triple.</p>
17+
18+
<p>We start with a bottom row of <code>bottom</code>, represented as a single string. We also start with a list of allowed triples <code>allowed</code>. Each allowed triple is represented as a string of length 3.</p>
19+
20+
<p>Return true if we can build the pyramid all the way to the top, otherwise false.</p>
21+
22+
<p><b>Example 1:</b></p>
23+
2524
<pre>
26-
<b>Input:</b> bottom = "XYZ", allowed = ["XYD", "YZE", "DEA", "FFF"]
25+
<b>Input:</b> bottom = &quot;BCD&quot;, allowed = [&quot;BCG&quot;, &quot;CDE&quot;, &quot;GEA&quot;, &quot;FFF&quot;]
2726
<b>Output:</b> true
2827
<b>Explanation:</b>
2928
We can stack the pyramid like this:
3029
A
3130
/ \
32-
D E
31+
G E
3332
/ \ / \
34-
X Y Z
33+
B C D
3534

36-
This works because ('X', 'Y', 'D'), ('Y', 'Z', 'E'), and ('D', 'E', 'A') are allowed triples.
37-
</pre>
38-
</p>
35+
We are allowed to place G on top of B and C because BCG is an allowed triple. Similarly, we can place E on top of C and D, then A on top of G and E.</pre>
36+
37+
<p>&nbsp;</p>
38+
39+
<p><b>Example 2:</b></p>
3940

40-
<p><b>Example 2:</b><br />
4141
<pre>
42-
<b>Input:</b> bottom = "XXYX", allowed = ["XXX", "XXY", "XYX", "XYY", "YXZ"]
42+
<b>Input:</b> bottom = &quot;AABA&quot;, allowed = [&quot;AAA&quot;, &quot;AAB&quot;, &quot;ABA&quot;, &quot;ABB&quot;, &quot;BAC&quot;]
4343
<b>Output:</b> false
4444
<b>Explanation:</b>
45-
We can't stack the pyramid to the top.
45+
We can&#39;t stack the pyramid to the top.
4646
Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D.
4747
</pre>
48-
</p>
4948

50-
<p><b>Note:</b><br>
49+
<p>&nbsp;</p>
50+
51+
<p><b>Note:</b></p>
52+
5153
<ol>
52-
<li><code>bottom</code> will be a string with length in range <code>[2, 8]</code>.</li>
53-
<li><code>allowed</code> will have length in range <code>[0, 200]</code>.</li>
54-
<li>Letters in all strings will be chosen from the set <code>{'A', 'B', 'C', 'D', 'E', 'F', 'G'}</code>.</li>
54+
<li><code>bottom</code> will be a string with length in range <code>[2, 8]</code>.</li>
55+
<li><code>allowed</code> will have length in range <code>[0, 200]</code>.</li>
56+
<li>Letters in all strings will be chosen from the set <code>{&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;, &#39;E&#39;, &#39;F&#39;, &#39;G&#39;}</code>.</li>
5557
</ol>
56-
</p>
58+
59+
<p>&nbsp;</p>
5760

5861
### Related Topics
5962
[[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)]

‎problems/uncrossed-lines/README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313

1414
<p>We write the integers of <code>A</code> and <code>B</code>&nbsp;(in the order they are given) on two separate horizontal lines.</p>
1515

16-
<p>Now, we may draw a straight line connecting two numbers <code>A[i]</code> and <code>B[j]</code> as long as <code>A[i] == B[j]</code>, and the line we draw does not intersect any other connecting (non-horizontal) line.</p>
16+
<p>Now, we may draw <em>connecting lines</em>: a straight line connecting two numbers <code>A[i]</code> and <code>B[j]</code>&nbsp;such that:</p>
17+
18+
<ul>
19+
<li><code>A[i] == B[j]</code>;</li>
20+
<li>The line we draw does not intersect any other connecting (non-horizontal) line.</li>
21+
</ul>
22+
23+
<p>Note that a connecting lines cannot intersect even at the endpoints:&nbsp;each number can only belong to one connecting line.</p>
1724

1825
<p>Return the maximum number of connecting lines we can draw in this way.</p>
1926

‎problems/valid-square/README.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@
1515

1616
<p>The coordinate (x,y) of a point is represented by an integer array with two integers.</p>
1717

18-
<p><b>Example:</b><br />
18+
<p><b>Example:</b></p>
19+
1920
<pre>
2021
<b>Input:</b> p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]
2122
<b>Output:</b> True
2223
</pre>
23-
</p>
2424

25-
<p> Note:
25+
<p>&nbsp;</p>
26+
27+
<p>Note:</p>
28+
2629
<ol>
27-
<li>All the input integers are in the range [-10000, 10000].</li>
28-
<li>A valid square has four equal sides with positive length and four equal angles (90-degree angles).</li>
29-
<li>Input points have no order.</li>
30+
<li>All the input integers are in the range [-10000, 10000].</li>
31+
<li>A valid square has four equal sides with positive length and four equal angles (90-degree angles).</li>
32+
<li>Input points have no order.</li>
3033
</ol>
31-
</p>
34+
35+
<p>&nbsp;</p>
3236

3337
### Related Topics
3438
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]

0 commit comments

Comments
(0)

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