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 2eac959

Browse files
committed
Update: description
1 parent 39f200b commit 2eac959

File tree

10 files changed

+165
-133
lines changed

10 files changed

+165
-133
lines changed

‎problems/count-student-number-in-departments/README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
## 580. Count Student Number in Departments (Medium)
1313

14-
<p>A university uses 2 data tables, <b><i>student</b></i> and <b><i>department</b></i>, to store data about its students and the departments associated with each major.</p>
14+
<p>A university uses 2 data tables, <b><i>student</i></b> and <b><i>department</i></b>, to store data about its students and the departments associated with each major.</p>
1515

16-
<p>Write a query to print the respective department name and number of students majoring in each department for all departments in the <b><i>department</b></i> table (even ones with no current students).</p>
16+
<p>Write a query to print the respective department name and number of students majoring in each department for all departments in the <b><i>department</i></b> table (even ones with no current students).</p>
1717

1818
<p>Sort your results by descending number of students; if two or more departments have the same number of students, then sort those departments alphabetically by department name.</p>
1919

20-
<p>The <b><i>student</b></i> is described as follow:</p>
20+
<p>The <b><i>student</i></b> is described as follow:</p>
2121

2222
<pre>
2323
| Column Name | Type |
@@ -28,21 +28,21 @@
2828
| dept_id | Integer |
2929
</pre>
3030

31-
<p>where student_id is the student's ID number, student_name is the student's name, gender is their gender, and dept_id is the department ID associated with their declared major.</p>
31+
<p>where student_id is the student&#39;s ID number, student_name is the student&#39;s name, gender is their gender, and dept_id is the department ID associated with their declared major.</p>
32+
33+
<p>And the <b><i>department</i></b> table is described as below:</p>
3234

33-
<p>And the <b><i>department</b></i> table is described as below:</p>
3435
<pre>
3536
| Column Name | Type |
3637
|-------------|---------|
3738
| dept_id | Integer |
3839
| dept_name | String |
3940
</pre>
4041

41-
<p>where dept_id is the department's ID number and dept_name is the department name.</p>
42-
43-
<p>Here is an example <b>input</b>:</br>
42+
<p>where dept_id is the department&#39;s ID number and dept_name is the department name.</p>
4443

45-
<b><i>student</b></i> table:</p>
44+
<p>Here is an example <b>input</b>:<br />
45+
<b><i>student</i></b> table:</p>
4646

4747
<pre>
4848
| student_id | student_name | gender | dept_id |
@@ -52,7 +52,8 @@
5252
| 3 | Mark | M | 2 |
5353
</pre>
5454

55-
<p><b><i>department</b></i> table:</p>
55+
<p><b><i>department</i></b> table:</p>
56+
5657
<pre>
5758
| dept_id | dept_name |
5859
|---------|-------------|
@@ -62,6 +63,7 @@
6263
</pre>
6364

6465
<p>The <b>Output</b> should be:</p>
66+
6567
<pre>
6668
| dept_name | student_number |
6769
|-------------|----------------|

‎problems/course-schedule-iii/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,33 @@
1111

1212
## 630. Course Schedule III (Hard)
1313

14-
<p>
15-
There are <code>n</code> different online courses numbered from <code>1</code> to <code>n</code>. Each course has some duration(course length) <code>t</code> and closed on <code>d<sub>th</sub></code> day. A course should be taken <b>continuously</b> for <code>t</code> days and must be finished before or on the <code>d<sub>th</sub></code> day. You will start at the <code>1<sub>st</sub></code> day.
16-
</p>
14+
<p>There are <code>n</code> different online courses numbered from <code>1</code> to <code>n</code>. Each course has some duration(course length) <code>t</code> and closed on <code>d<sub>th</sub></code> day. A course should be taken <b>continuously</b> for <code>t</code> days and must be finished before or on the <code>d<sub>th</sub></code> day. You will start at the <code>1<sub>st</sub></code> day.</p>
1715

18-
<p>
19-
Given <code>n</code> online courses represented by pairs <code>(t,d)</code>, your task is to find the maximal number of courses that can be taken.
20-
</p>
16+
<p>Given <code>n</code> online courses represented by pairs <code>(t,d)</code>, your task is to find the maximal number of courses that can be taken.</p>
2117

18+
<p><b>Example:</b></p>
2219

23-
<p><b>Example:</b><br />
2420
<pre>
2521
<b>Input:</b> [[100, 200], [200, 1300], [1000, 1250], [2000, 3200]]
2622
<b>Output:</b> 3
2723
<b>Explanation:</b>
28-
There're totally 4 courses, but you can take 3 courses at most:
24+
There&#39;re totally 4 courses, but you can take 3 courses at most:
2925
First, take the 1st course, it costs 100 days so you will finish it on the 100th day, and ready to take the next course on the 101st day.
3026
Second, take the 3rd course, it costs 1000 days so you will finish it on the 1100th day, and ready to take the next course on the 1101st day.
3127
Third, take the 2nd course, it costs 200 days so you will finish it on the 1300th day.
3228
The 4th course cannot be taken now, since you will finish it on the 3300th day, which exceeds the closed date.
3329
</pre>
34-
</p>
3530

31+
<p>&nbsp;</p>
32+
33+
<p><b>Note:</b></p>
3634

37-
<p><b>Note:</b><br>
3835
<ol>
39-
<li>The integer 1 <= d, t, n <= 10,000.</li>
40-
<li>You can't take two courses simultaneously.</li>
36+
<li>The integer 1 &lt;= d, t, n &lt;= 10,000.</li>
37+
<li>You can&#39;t take two courses simultaneously.</li>
4138
</ol>
42-
</p>
39+
40+
<p>&nbsp;</p>
4341

4442
### Related Topics
4543
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]

‎problems/customer-placing-the-largest-number-of-orders/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</pre>
3131

3232
<p><b>Sample Input</b></p>
33+
3334
<pre>
3435
| order_number | customer_number | order_date | required_date | shipped_date | status | comment |
3536
|--------------|-----------------|------------|---------------|--------------|--------|---------|
@@ -40,15 +41,18 @@
4041
</pre>
4142

4243
<p><b>Sample Output</b></p>
44+
4345
<pre>
4446
| customer_number |
4547
|-----------------|
4648
| 3 |
4749
</pre>
4850

4951
<p><b>Explanation</b></p>
52+
5053
<pre>
51-
The customer with number '3' has two orders, which is greater than either customer '1' or '2' because each of them only has one order. </br>So the result is customer_number '3'.
54+
The customer with number &#39;3&#39; has two orders, which is greater than either customer &#39;1&#39; or &#39;2&#39; because each of them only has one order.
55+
So the result is customer_number &#39;3&#39;.
5256
</pre>
5357

5458
<p><i><b>Follow up:</b> What if more than one customer have the largest number of orders, can you find all the customer_number in this case?</i></p>

‎problems/cut-off-trees-for-golf-event/README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@
1111

1212
## 675. Cut Off Trees for Golf Event (Hard)
1313

14-
<p>
15-
You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-negative 2D map, in this map:
14+
<p>You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-negative 2D map, in this map:</p>
15+
1616
<ol>
17-
<li><code>0</code> represents the <code>obstacle</code> can't be reached.</li>
18-
<li><code>1</code> represents the <code>ground</code> can be walked through.</li>
19-
<li><code>The place with number bigger than 1</code> represents a <code>tree</code> can be walked through, and this positive number represents the tree's height.</li>
17+
<li><code>0</code> represents the <code>obstacle</code> can&#39;t be reached.</li>
18+
<li><code>1</code> represents the <code>ground</code> can be walked through.</li>
19+
<li><code>The place with number bigger than 1</code> represents a <code>tree</code> can be walked through, and this positive number represents the tree&#39;s height.</li>
2020
</ol>
21-
</p>
2221

23-
<p>
24-
You are asked to cut off <b>all</b> the trees in this forest in the order of tree's height - always cut off the tree with lowest height first. And after cutting, the original place has the tree will become a grass (value 1).
25-
</p>
22+
<p>&nbsp;</p>
23+
24+
<p>You are asked to cut off <b>all</b> the trees in this forest in the order of tree&#39;s height - always cut off the tree with lowest height first. And after cutting, the original place has the tree will become a grass (value 1).</p>
2625

27-
<p>
28-
You will start from the point (0, 0) and you should output the minimum steps <b>you need to walk</b> to cut off all the trees. If you can't cut off all the trees, output -1 in that situation.
29-
</p>
26+
<p>You will start from the point (0, 0) and you should output the minimum steps <b>you need to walk</b> to cut off all the trees. If you can&#39;t cut off all the trees, output -1 in that situation.</p>
3027

31-
<p>
32-
You are guaranteed that no two <code>trees</code> have the same height and there is at least one tree needs to be cut off.
33-
</p>
28+
<p>You are guaranteed that no two <code>trees</code> have the same height and there is at least one tree needs to be cut off.</p>
29+
30+
<p><b>Example 1:</b></p>
3431

35-
<p><b>Example 1:</b><br />
3632
<pre>
3733
<b>Input:</b>
3834
[
@@ -42,9 +38,11 @@ You are guaranteed that no two <code>trees</code> have the same height and there
4238
]
4339
<b>Output:</b> 6
4440
</pre>
45-
</p>
4641

47-
<p><b>Example 2:</b><br />
42+
<p>&nbsp;</p>
43+
44+
<p><b>Example 2:</b></p>
45+
4846
<pre>
4947
<b>Input:</b>
5048
[
@@ -54,9 +52,11 @@ You are guaranteed that no two <code>trees</code> have the same height and there
5452
]
5553
<b>Output:</b> -1
5654
</pre>
57-
</p>
5855

59-
<p><b>Example 3:</b><br />
56+
<p>&nbsp;</p>
57+
58+
<p><b>Example 3:</b></p>
59+
6060
<pre>
6161
<b>Input:</b>
6262
[
@@ -67,11 +67,10 @@ You are guaranteed that no two <code>trees</code> have the same height and there
6767
<b>Output:</b> 6
6868
<b>Explanation:</b> You started from the point (0,0) and you can cut off the tree in (0,0) directly without walking.
6969
</pre>
70-
</p>
7170

72-
<p>
73-
<b>Hint</b>: size of the given matrix will not exceed 50x50.
74-
</p>
71+
<p>&nbsp;</p>
72+
73+
<p><b>Hint</b>: size of the given matrix will not exceed 50x50.</p>
7574

7675
### Related Topics
7776
[[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)]

‎problems/delete-and-earn/README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,45 @@
1111

1212
## 740. Delete and Earn (Medium)
1313

14-
<p>
15-
Given an array <code>nums</code> of integers, you can perform operations on the array.
16-
</p><p>
17-
In each operation, you pick any <code>nums[i]</code> and delete it to earn <code>nums[i]</code> points. After, you must delete <b>every</b> element equal to <code>nums[i] - 1</code> or <code>nums[i] + 1</code>.
18-
</p><p>
19-
You start with 0 points. Return the maximum number of points you can earn by applying such operations.
20-
</p>
21-
22-
<p><b>Example 1:</b><br />
14+
<p>Given an array <code>nums</code> of integers, you can perform operations on the array.</p>
15+
16+
<p>In each operation, you pick any <code>nums[i]</code> and delete it to earn <code>nums[i]</code> points. After, you must delete <b>every</b> element equal to <code>nums[i] - 1</code> or <code>nums[i] + 1</code>.</p>
17+
18+
<p>You start with 0 points. Return the maximum number of points you can earn by applying such operations.</p>
19+
20+
<p><b>Example 1:</b></p>
21+
2322
<pre>
2423
<b>Input:</b> nums = [3, 4, 2]
2524
<b>Output:</b> 6
2625
<b>Explanation:</b>
2726
Delete 4 to earn 4 points, consequently 3 is also deleted.
2827
Then, delete 2 to earn 2 points. 6 total points are earned.
2928
</pre>
30-
</p>
3129

32-
<p><b>Example 2:</b><br />
30+
<p>&nbsp;</p>
31+
32+
<p><b>Example 2:</b></p>
33+
3334
<pre>
3435
<b>Input:</b> nums = [2, 2, 3, 3, 3, 4]
3536
<b>Output:</b> 9
3637
<b>Explanation:</b>
37-
Delete 3 to earn 3 points, deleting both 2's and the 4.
38+
Delete 3 to earn 3 points, deleting both 2&#39;s and the 4.
3839
Then, delete 3 again to earn 3 points, and 3 again to earn 3 points.
3940
9 total points are earned.
4041
</pre>
41-
</p>
4242

43-
<p><b>Note:</b>
44-
<li>The length of <code>nums</code> is at most <code>20000</code>.</li>
45-
<li>Each element <code>nums[i]</code> is an integer in the range <code>[1, 10000]</code>.</li>
46-
</p>
43+
<p>&nbsp;</p>
44+
45+
<p><b>Note:</b></p>
46+
47+
<ul>
48+
<li>The length of <code>nums</code> is at most <code>20000</code>.</li>
49+
<li>Each element <code>nums[i]</code> is an integer in the range <code>[1, 10000]</code>.</li>
50+
</ul>
51+
52+
<p>&nbsp;</p>
4753

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

‎problems/dota2-senate/README.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,58 @@
1111

1212
## 649. Dota2 Senate (Medium)
1313

14-
<p>
15-
In the world of Dota2, there are two parties: the <code>Radiant</code> and the <code>Dire</code>.
16-
</p>
14+
<p>In the world of Dota2, there are two parties: the <code>Radiant</code> and the <code>Dire</code>.</p>
15+
16+
<p>The Dota2 senate consists of senators coming from two parties. Now the senate wants to make a decision about a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can exercise <code>one</code> of the two rights:</p>
1717

18-
<p>
19-
The Dota2 senate consists of senators coming from two parties. Now the senate wants to make a decision about a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can exercise <code>one</code> of the two rights:
2018
<ol>
21-
<li><code>Ban one senator's right</code>: <br/>A senator can make another senator lose <b>all his rights</b> in this and all the following rounds.</li>
22-
<li><code>Announce the victory</code>: <br/>If this senator found the senators who still have rights to vote are all from <b>the same party</b>, he can announce the victory and make the decision about the change in the game.</li>
19+
<li><code>Ban one senator&#39;s right</code>:<br />
20+
A senator can make another senator lose <b>all his rights</b> in this and all the following rounds.</li>
21+
<li><code>Announce the victory</code>:<br />
22+
If this senator found the senators who still have rights to vote are all from <b>the same party</b>, he can announce the victory and make the decision about the change in the game.</li>
2323
</ol>
24-
</p>
2524

26-
<p>
27-
Given a string representing each senator's party belonging. The character 'R' and 'D' represent the <code>Radiant</code> party and the <code>Dire</code> party respectively. Then if there are <code>n</code> senators, the size of the given string will be <code>n</code>.
28-
</p>
25+
<p>&nbsp;</p>
26+
27+
<p>Given a string representing each senator&#39;s party belonging. The character &#39;R&#39; and &#39;D&#39; represent the <code>Radiant</code> party and the <code>Dire</code> party respectively. Then if there are <code>n</code> senators, the size of the given string will be <code>n</code>.</p>
2928

30-
<p>
31-
The round-based procedure starts from the first senator to the last senator in the given order. This procedure will last until the end of voting. All the senators who have lost their rights will be skipped during the procedure.
32-
</p>
29+
<p>The round-based procedure starts from the first senator to the last senator in the given order. This procedure will last until the end of voting. All the senators who have lost their rights will be skipped during the procedure.</p>
3330

34-
<p>
35-
Suppose every senator is smart enough and will play the best strategy for his own party, you need to predict which party will finally announce the victory and make the change in the Dota2 game. The output should be <code>Radiant</code> or <code>Dire</code>.
36-
</p>
31+
<p>Suppose every senator is smart enough and will play the best strategy for his own party, you need to predict which party will finally announce the victory and make the change in the Dota2 game. The output should be <code>Radiant</code> or <code>Dire</code>.</p>
32+
33+
<p><b>Example 1:</b></p>
3734

38-
<p><b>Example 1:</b><br />
3935
<pre>
40-
<b>Input:</b> "RD"
41-
<b>Output:</b> "Radiant"
42-
<b>Explanation:</b> The first senator comes from Radiant and he can just ban the next senator's right in the round 1. <br/>And the second senator can't exercise any rights any more since his right has been banned. <br/>And in the round 2, the first senator can just announce the victory since he is the only guy in the senate who can vote.
36+
<b>Input:</b> &quot;RD&quot;
37+
<b>Output:</b> &quot;Radiant&quot;
38+
<b>Explanation:</b> The first senator comes from Radiant and he can just ban the next senator&#39;s right in the round 1.
39+
And the second senator can&#39;t exercise any rights any more since his right has been banned.
40+
And in the round 2, the first senator can just announce the victory since he is the only guy in the senate who can vote.
4341
</pre>
44-
</p>
4542

43+
<p>&nbsp;</p>
44+
45+
<p><b>Example 2:</b></p>
4646

47-
<p><b>Example 2:</b><br />
4847
<pre>
49-
<b>Input:</b> "RDD"
50-
<b>Output:</b> "Dire"
48+
<b>Input:</b> &quot;RDD&quot;
49+
<b>Output:</b> &quot;Dire&quot;
5150
<b>Explanation:</b>
52-
The first senator comes from Radiant and he can just ban the next senator's right in the round 1. <br/>And the second senator can't exercise any rights anymore since his right has been banned. <br/>And the third senator comes from Dire and he can ban the first senator's right in the round 1. <br/>And in the round 2, the third senator can just announce the victory since he is the only guy in the senate who can vote.
51+
The first senator comes from Radiant and he can just ban the next senator&#39;s right in the round 1.
52+
And the second senator can&#39;t exercise any rights anymore since his right has been banned.
53+
And the third senator comes from Dire and he can ban the first senator&#39;s right in the round 1.
54+
And in the round 2, the third senator can just announce the victory since he is the only guy in the senate who can vote.
5355
</pre>
54-
</p>
5556

56-
<p><b>Note:</b><br>
57+
<p>&nbsp;</p>
58+
59+
<p><b>Note:</b></p>
60+
5761
<ol>
58-
<li>The length of the given string will in the range [1, 10,000].</li>
62+
<li>The length of the given string will in the range [1, 10,000].</li>
5963
</ol>
60-
</p>
64+
65+
<p>&nbsp;</p>
6166

6267
### Related Topics
6368
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]

0 commit comments

Comments
(0)

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