Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct Node {
<ul>
<li>You may only use constant extra space.</li>
<li>Recursive approach is fine, implicit stack space does not count as extra space for this problem.</li>
<li>You may assume that it is a perfect binary tree (i.e., all leaves are on the same level, and every parent has two children).</li>
</ul>

### Related Topics
Expand Down
29 changes: 19 additions & 10 deletions problems/students-report-by-geography/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@

## 618. Students Report By Geography (Hard)

A U.S graduate school has students from Asia, Europe and America. The students' location information are stored in table <code>student</code> as below.</p>

A U.S graduate school has students from Asia, Europe and America. The students&#39; location information are stored in table <code>student</code> as below.
<p>&nbsp;</p>

<pre>
| name | continent |
|--------|-----------|
| Jack | America |
| Pascal | Europe |
| Xi | Asia |
| Jane | America |
</pre></p>

<a href="https://en.wikipedia.org/wiki/Pivot_table"> Pivot</a> the continent column in this table so that each name is sorted alphabetically and displayed underneath its corresponding continent. The output headers should be America, Asia and Europe respectively. It is guaranteed that the student number from America is no less than either Asia or Europe.</p>

For the sample input, the output is:</p>
</pre>

<p>&nbsp;</p>
<a href="https://en.wikipedia.org/wiki/Pivot_table"> Pivot</a> the continent column in this table so that each name is sorted alphabetically and displayed underneath its corresponding continent. The output headers should be America, Asia and Europe respectively. It is guaranteed that the student number from America is no less than either Asia or Europe.

<p>&nbsp;</p>
For the sample input, the output is:

<p>&nbsp;</p>

<pre>
| America | Asia | Europe |
|---------|------|--------|
| Jack | Xi | Pascal |
| Jane | | |
</pre></p>

<b>Follow-up:</b> If it is unknown which continent has the most students, can you write a query to generate the student report?</p>
</pre>

<p>&nbsp;</p>
<b>Follow-up:</b> If it is unknown which continent has the most students, can you write a query to generate the student report?

<p>&nbsp;</p>
11 changes: 7 additions & 4 deletions problems/swap-salary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

## 627. Swap Salary (Easy)

Given a table <code>salary</code>, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate temp table.</p>

For example:</p>

Given a table <code>salary</code>, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate temp table.
<p>&nbsp;</p>
For example:

<p>&nbsp;</p>

<pre>
| id | name | sex | salary |
|----|------|-----|--------|
Expand All @@ -24,6 +26,7 @@ For example:</p>
| 4 | D | f | 500 |
</pre>
After running your query, the above salary table should have the following rows:

<pre>
| id | name | sex | salary |
|----|------|-----|--------|
Expand Down
12 changes: 9 additions & 3 deletions problems/winning-candidate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## 574. Winning Candidate (Medium)

<p>Table: <code>Candidate</code></p>

<pre>
+-----+---------+
| id | Name |
Expand All @@ -23,7 +24,9 @@
| 5 | E |
+-----+---------+
</pre>

<p>Table: <code>Vote</code></p>

<pre>
+-----+--------------+
| id | CandidateId |
Expand All @@ -48,7 +51,10 @@ CandidateId is the id appeared in Candidate table.
+------+
</pre>

<p><b>Notes:</b><br />
<p><b>Notes:</b></p>

<ol>
<li>You may assume <b>there is no tie</b>, in other words there will be <b>at most one</b> winning candidate.</li>
</ol></p>
<li>You may assume <b>there is no tie</b>, in other words there will be <b>at most one</b> winning candidate.</li>
</ol>

<p>&nbsp;</p>