Skip to content

Commit 00f6236

Browse files
author
Shuo
authored
Merge pull request #410 from openset/develop
Update: description
2 parents 4fb1203 + 8d5e250 commit 00f6236

File tree

10 files changed

+129
-115
lines changed

10 files changed

+129
-115
lines changed

problems/managers-with-at-least-5-direct-reports/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
+------+----------+-----------+----------+
2727
</pre>
2828

29-
<p>Given the <code>Employee</code> table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return:
30-
</p>
29+
<p>Given the <code>Employee</code> table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return:</p>
3130

3231
<pre>
3332
+-------+

problems/maximum-average-subarray-i/README.md

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

1212
## 643. Maximum Average Subarray I (Easy)
1313

14-
<p>
15-
Given an array consisting of <code>n</code> integers, find the contiguous subarray of given length <code>k</code> that has the maximum average value. And you need to output the maximum average value.
16-
</p>
14+
<p>Given an array consisting of <code>n</code> integers, find the contiguous subarray of given length <code>k</code> that has the maximum average value. And you need to output the maximum average value.</p>
15+
16+
<p><b>Example 1:</b></p>
1717

18-
<p><b>Example 1:</b><br />
1918
<pre>
2019
<b>Input:</b> [1,12,-5,-6,50,3], k = 4
2120
<b>Output:</b> 12.75
2221
<b>Explanation:</b> Maximum average is (12-5-6+50)/4 = 51/4 = 12.75
2322
</pre>
24-
</p>
2523

26-
<p><b>Note:</b><br>
24+
<p>&nbsp;</p>
25+
26+
<p><b>Note:</b></p>
27+
2728
<ol>
28-
<li>1 <= <code>k</code> <= <code>n</code> <= 30,000.</li>
29-
<li>Elements of the given array will be in the range [-10,000, 10,000].</li>
29+
<li>1 &lt;= <code>k</code> &lt;= <code>n</code> &lt;= 30,000.</li>
30+
<li>Elements of the given array will be in the range [-10,000, 10,000].</li>
3031
</ol>
31-
</p>
32+
33+
<p>&nbsp;</p>
3234

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

problems/maximum-product-of-three-numbers/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,32 @@
1313

1414
<p>Given an integer array, find three numbers whose product is maximum and output the maximum product.</p>
1515

16-
<p><b>Example 1:</b><br />
16+
<p><b>Example 1:</b></p>
17+
1718
<pre>
1819
<b>Input:</b> [1,2,3]
1920
<b>Output:</b> 6
2021
</pre>
21-
</p>
2222

23-
<p><b>Example 2:</b><br />
23+
<p>&nbsp;</p>
24+
25+
<p><b>Example 2:</b></p>
26+
2427
<pre>
2528
<b>Input:</b> [1,2,3,4]
2629
<b>Output:</b> 24
2730
</pre>
28-
</p>
2931

30-
<p><b>Note:</b><br>
32+
<p>&nbsp;</p>
33+
34+
<p><b>Note:</b></p>
35+
3136
<ol>
32-
<li>The length of the given array will be in range [3,10<sup>4</sup>] and all elements are in the range [-1000, 1000].</li>
33-
<li>Multiplication of any three numbers in the input won't exceed the range of 32-bit signed integer.</li>
37+
<li>The length of the given array will be in range [3,10<sup>4</sup>] and all elements are in the range [-1000, 1000].</li>
38+
<li>Multiplication of any three numbers in the input won&#39;t exceed the range of 32-bit signed integer.</li>
3439
</ol>
35-
</p>
40+
41+
<p>&nbsp;</p>
3642

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

problems/maximum-width-of-binary-tree/README.md

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

1212
## 662. Maximum Width of Binary Tree (Medium)
1313

14-
<p>Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a <b>full binary tree</b>, but some nodes are null. </p>
14+
<p>Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a <b>full binary tree</b>, but some nodes are null.</p>
1515

1616
<p>The width of one level is defined as the length between the end-nodes (the leftmost and right most non-null nodes in the level, where the <code>null</code> nodes between the end-nodes are also counted into the length calculation.</p>
1717

18-
<p><b>Example 1:</b><br />
18+
<p><b>Example 1:</b></p>
19+
1920
<pre>
2021
<b>Input:</b>
2122

@@ -29,8 +30,8 @@
2930
<b>Explanation:</b> The maximum width existing in the third level with the length 4 (5,3,null,9).
3031
</pre>
3132

33+
<p><b>Example 2:</b></p>
3234

33-
<p><b>Example 2:</b><br />
3435
<pre>
3536
<b>Input:</b>
3637

@@ -44,8 +45,8 @@
4445
<b>Explanation:</b> The maximum width existing in the third level with the length 2 (5,3).
4546
</pre>
4647

48+
<p><b>Example 3:</b></p>
4749

48-
<p><b>Example 3:</b><br />
4950
<pre>
5051
<b>Input:</b>
5152

@@ -59,7 +60,8 @@
5960
<b>Explanation:</b> The maximum width existing in the second level with the length 2 (3,2).
6061
</pre>
6162

62-
<p><b>Example 4:</b><br />
63+
<p><b>Example 4:</b></p>
64+
6365
<pre>
6466
<b>Input:</b>
6567

@@ -76,9 +78,7 @@
7678

7779
</pre>
7880

79-
<p><b>Note:</b>
80-
Answer will in the range of 32-bit signed integer.
81-
</p>
81+
<p><b>Note:</b> Answer will in the range of 32-bit signed integer.</p>
8282

8383
### Related Topics
8484
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]

problems/median-employee-salary/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
## 569. Median Employee Salary (Hard)
1313

14-
<p>
15-
The <code>Employee</code> table holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.</p>
14+
<p>The <code>Employee</code> table holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.</p>
1615

1716
<pre>
1817
+-----+------------+--------+

problems/my-calendar-i/README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,37 @@
1111

1212
## 729. My Calendar I (Medium)
1313

14-
<p>
15-
Implement a <code>MyCalendar</code> class to store your events. A new event can be added if adding the event will not cause a double booking.
16-
</p><p>
17-
Your class will have the method, <code>book(int start, int end)</code>. Formally, this represents a booking on the half open interval <code>[start, end)</code>, the range of real numbers <code>x</code> such that <code>start <= x < end</code>.
18-
</p><p>
19-
A <i>double booking</i> happens when two events have some non-empty intersection (ie., there is some time that is common to both events.)
20-
</p><p>
21-
For each call to the method <code>MyCalendar.book</code>, return <code>true</code> if the event can be added to the calendar successfully without causing a double booking. Otherwise, return <code>false</code> and do not add the event to the calendar.
22-
</p>
23-
24-
Your class will be called like this:
25-
<code>MyCalendar cal = new MyCalendar();</code>
26-
<code>MyCalendar.book(start, end)</code>
27-
28-
<p><b>Example 1:</b><br />
14+
<p>Implement a <code>MyCalendar</code> class to store your events. A new event can be added if adding the event will not cause a double booking.</p>
15+
16+
<p>Your class will have the method, <code>book(int start, int end)</code>. Formally, this represents a booking on the half open interval <code>[start, end)</code>, the range of real numbers <code>x</code> such that <code>start &lt;= x &lt; end</code>.</p>
17+
18+
<p>A <i>double booking</i> happens when two events have some non-empty intersection (ie., there is some time that is common to both events.)</p>
19+
20+
<p>For each call to the method <code>MyCalendar.book</code>, return <code>true</code> if the event can be added to the calendar successfully without causing a double booking. Otherwise, return <code>false</code> and do not add the event to the calendar.</p>
21+
Your class will be called like this: <code>MyCalendar cal = new MyCalendar();</code> <code>MyCalendar.book(start, end)</code>
22+
23+
<p><b>Example 1:</b></p>
24+
2925
<pre>
3026
MyCalendar();
3127
MyCalendar.book(10, 20); // returns true
3228
MyCalendar.book(15, 25); // returns false
3329
MyCalendar.book(20, 30); // returns true
3430
<b>Explanation:</b>
35-
The first event can be booked. The second can't because time 15 is already booked by another event.
31+
The first event can be booked. The second can&#39;t because time 15 is already booked by another event.
3632
The third event can be booked, as the first event takes every time less than 20, but not including 20.
3733
</pre>
38-
</p>
3934

40-
<p><b>Note:</b>
41-
<li>The number of calls to <code>MyCalendar.book</code> per test case will be at most <code>1000</code>.</li>
42-
<li>In calls to <code>MyCalendar.book(start, end)</code>, <code>start</code> and <code>end</code> are integers in the range <code>[0, 10^9]</code>.</li>
43-
</p>
35+
<p>&nbsp;</p>
36+
37+
<p><b>Note:</b></p>
38+
39+
<ul>
40+
<li>The number of calls to <code>MyCalendar.book</code> per test case will be at most <code>1000</code>.</li>
41+
<li>In calls to <code>MyCalendar.book(start, end)</code>, <code>start</code> and <code>end</code> are integers in the range <code>[0, 10^9]</code>.</li>
42+
</ul>
43+
44+
<p>&nbsp;</p>
4445

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

problems/my-calendar-ii/README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@
1111

1212
## 731. My Calendar II (Medium)
1313

14-
<p>
15-
Implement a <code>MyCalendarTwo</code> class to store your events. A new event can be added if adding the event will not cause a <b>triple</b> booking.
16-
</p><p>
17-
Your class will have one method, <code>book(int start, int end)</code>. Formally, this represents a booking on the half open interval <code>[start, end)</code>, the range of real numbers <code>x</code> such that <code>start <= x < end</code>.
18-
</p><p>
19-
A <i>triple booking</i> happens when <b>three</b> events have some non-empty intersection (ie., there is some time that is common to all 3 events.)
20-
</p><p>
21-
For each call to the method <code>MyCalendar.book</code>, return <code>true</code> if the event can be added to the calendar successfully without causing a <b>triple</b> booking. Otherwise, return <code>false</code> and do not add the event to the calendar.
22-
</p>
23-
24-
Your class will be called like this:
25-
<code>MyCalendar cal = new MyCalendar();</code>
26-
<code>MyCalendar.book(start, end)</code>
27-
28-
<p><b>Example 1:</b><br />
14+
<p>Implement a <code>MyCalendarTwo</code> class to store your events. A new event can be added if adding the event will not cause a <b>triple</b> booking.</p>
15+
16+
<p>Your class will have one method, <code>book(int start, int end)</code>. Formally, this represents a booking on the half open interval <code>[start, end)</code>, the range of real numbers <code>x</code> such that <code>start &lt;= x &lt; end</code>.</p>
17+
18+
<p>A <i>triple booking</i> happens when <b>three</b> events have some non-empty intersection (ie., there is some time that is common to all 3 events.)</p>
19+
20+
<p>For each call to the method <code>MyCalendar.book</code>, return <code>true</code> if the event can be added to the calendar successfully without causing a <b>triple</b> booking. Otherwise, return <code>false</code> and do not add the event to the calendar.</p>
21+
Your class will be called like this: <code>MyCalendar cal = new MyCalendar();</code> <code>MyCalendar.book(start, end)</code>
22+
23+
<p><b>Example 1:</b></p>
24+
2925
<pre>
3026
MyCalendar();
3127
MyCalendar.book(10, 20); // returns true
@@ -36,17 +32,22 @@ MyCalendar.book(5, 10); // returns true
3632
MyCalendar.book(25, 55); // returns true
3733
<b>Explanation:</b>
3834
The first two events can be booked. The third event can be double booked.
39-
The fourth event (5, 15) can't be booked, because it would result in a triple booking.
35+
The fourth event (5, 15) can&#39;t be booked, because it would result in a triple booking.
4036
The fifth event (5, 10) can be booked, as it does not use time 10 which is already double booked.
4137
The sixth event (25, 55) can be booked, as the time in [25, 40) will be double booked with the third event;
4238
the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event.
4339
</pre>
44-
</p>
4540

46-
<p><b>Note:</b>
47-
<li>The number of calls to <code>MyCalendar.book</code> per test case will be at most <code>1000</code>.</li>
48-
<li>In calls to <code>MyCalendar.book(start, end)</code>, <code>start</code> and <code>end</code> are integers in the range <code>[0, 10^9]</code>.</li>
49-
</p>
41+
<p>&nbsp;</p>
42+
43+
<p><b>Note:</b></p>
44+
45+
<ul>
46+
<li>The number of calls to <code>MyCalendar.book</code> per test case will be at most <code>1000</code>.</li>
47+
<li>In calls to <code>MyCalendar.book(start, end)</code>, <code>start</code> and <code>end</code> are integers in the range <code>[0, 10^9]</code>.</li>
48+
</ul>
49+
50+
<p>&nbsp;</p>
5051

5152
### Related Topics
5253
[[Binary Search Tree](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md)]

problems/not-boring-movies/README.md

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

1212
## 620. Not Boring Movies (Easy)
1313

14-
X city opened a new cinema, many people would like to go to this cinema.
15-
The cinema also gives out a poster indicating the movies’ ratings and descriptions. <p/>
16-
17-
Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rating.
18-
<p/>
19-
<p>
20-
For example, table <code>cinema</code>:
14+
X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies&rsquo; ratings and descriptions.
15+
<p>Please write a SQL query to output movies with an odd numbered ID and a description that is not &#39;boring&#39;. Order the result by rating.</p>
16+
17+
<p>&nbsp;</p>
18+
19+
<p>For example, table <code>cinema</code>:</p>
20+
2121
<pre>
2222
+---------+-----------+--------------+-----------+
2323
| id | movie | description | rating |
@@ -30,6 +30,7 @@ For example, table <code>cinema</code>:
3030
+---------+-----------+--------------+-----------+
3131
</pre>
3232
For the example above, the output should be:
33+
3334
<pre>
3435
+---------+-----------+--------------+-----------+
3536
| id | movie | description | rating |
@@ -38,4 +39,5 @@ For the example above, the output should be:
3839
| 1 | War | great 3D | 8.9 |
3940
+---------+-----------+--------------+-----------+
4041
</pre>
41-
</p>
42+
43+
<p>&nbsp;</p>

problems/palindromic-substrings/README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,37 @@
1111

1212
## 647. Palindromic Substrings (Medium)
1313

14-
<p>
15-
Given a string, your task is to count how many palindromic substrings in this string.
16-
</p>
14+
<p>Given a string, your task is to count how many palindromic substrings in this string.</p>
1715

18-
<p>
19-
The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.
20-
</p>
16+
<p>The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.</p>
17+
18+
<p><b>Example 1:</b></p>
2119

22-
<p><b>Example 1:</b><br />
2320
<pre>
24-
<b>Input:</b> "abc"
21+
<b>Input:</b> &quot;abc&quot;
2522
<b>Output:</b> 3
26-
<b>Explanation:</b> Three palindromic strings: "a", "b", "c".
23+
<b>Explanation:</b> Three palindromic strings: &quot;a&quot;, &quot;b&quot;, &quot;c&quot;.
2724
</pre>
28-
</p>
2925

30-
<p><b>Example 2:</b><br />
26+
<p>&nbsp;</p>
27+
28+
<p><b>Example 2:</b></p>
29+
3130
<pre>
32-
<b>Input:</b> "aaa"
31+
<b>Input:</b> &quot;aaa&quot;
3332
<b>Output:</b> 6
34-
<b>Explanation:</b> Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
33+
<b>Explanation:</b> Six palindromic strings: &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;aa&quot;, &quot;aa&quot;, &quot;aaa&quot;.
3534
</pre>
36-
</p>
3735

38-
<p><b>Note:</b><br>
36+
<p>&nbsp;</p>
37+
38+
<p><b>Note:</b></p>
39+
3940
<ol>
40-
<li>The input string length won't exceed 1000.</li>
41+
<li>The input string length won&#39;t exceed 1000.</li>
4142
</ol>
42-
</p>
43+
44+
<p>&nbsp;</p>
4345

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

0 commit comments

Comments
 (0)