Skip to content

Commit fee7206

Browse files
committed
Create README - LeetHub
1 parent a617610 commit fee7206

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h2><a href="https://leetcode.com/problems/rearrange-products-table">1948. Rearrange Products Table</a></h2><h3>Easy</h3><hr><p>Table: <code>Products</code></p>
2+
3+
<pre>
4+
+-------------+---------+
5+
| Column Name | Type |
6+
+-------------+---------+
7+
| product_id | int |
8+
| store1 | int |
9+
| store2 | int |
10+
| store3 | int |
11+
+-------------+---------+
12+
product_id is the primary key (column with unique values) for this table.
13+
Each row in this table indicates the product&#39;s price in 3 different stores: store1, store2, and store3.
14+
If the product is not available in a store, the price will be null in that store&#39;s column.
15+
</pre>
16+
17+
<p>&nbsp;</p>
18+
19+
<p>Write a solution to rearrange the <code>Products</code> table so that each row has <code>(product_id, store, price)</code>. If a product is not available in a store, do <strong>not</strong> include a row with that <code>product_id</code> and <code>store</code> combination in the result table.</p>
20+
21+
<p>Return the result table in <strong>any order</strong>.</p>
22+
23+
<p>The result format is in the following example.</p>
24+
25+
<p>&nbsp;</p>
26+
<p><strong class="example">Example 1:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong>
30+
Products table:
31+
+------------+--------+--------+--------+
32+
| product_id | store1 | store2 | store3 |
33+
+------------+--------+--------+--------+
34+
| 0 | 95 | 100 | 105 |
35+
| 1 | 70 | null | 80 |
36+
+------------+--------+--------+--------+
37+
<strong>Output:</strong>
38+
+------------+--------+-------+
39+
| product_id | store | price |
40+
+------------+--------+-------+
41+
| 0 | store1 | 95 |
42+
| 0 | store2 | 100 |
43+
| 0 | store3 | 105 |
44+
| 1 | store1 | 70 |
45+
| 1 | store3 | 80 |
46+
+------------+--------+-------+
47+
<strong>Explanation:</strong>
48+
Product 0 is available in all three stores with prices 95, 100, and 105 respectively.
49+
Product 1 is available in store1 with price 70 and store3 with price 80. The product is not available in store2.
50+
</pre>

0 commit comments

Comments
 (0)