Skip to content

Commit 70527e6

Browse files
committed
deploy: 7f10b62
1 parent 3a143e7 commit 70527e6

File tree

28 files changed

+539
-376
lines changed

28 files changed

+539
-376
lines changed

en/lc/11/index.html

Lines changed: 63 additions & 66 deletions
Large diffs are not rendered by default.

en/lc/1154/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81433,7 +81433,7 @@ <h2 id="description">Description</h2>
8143381433
<ul>
8143481434
<li><code>date.length == 10</code></li>
8143581435
<li><code>date[4] == date[7] == &#39;-&#39;</code>, and all other <code>date[i]</code>&#39;s are digits</li>
81436-
<li><code>date</code> represents a calendar date between Jan 1<sup>st</sup>, 1900 and Dec 31<sup>th</sup>, 2019.</li>
81436+
<li><code>date</code> represents a calendar date between Jan 1<sup>st</sup>, 1900 and Dec 31<sup>st</sup>, 2019.</li>
8143781437
</ul>
8143881438

8143981439
<!-- description:end -->

en/lc/130/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81444,7 +81444,7 @@ <h2 id="description">Description</h2>
8144481444
<li><strong>Surround</strong>: The region is surrounded with <code>&#39;X&#39;</code> cells if you can <strong>connect the region </strong>with <code>&#39;X&#39;</code> cells and none of the region cells are on the edge of the <code>board</code>.</li>
8144581445
</ul>
8144681446

81447-
<p>A <strong>surrounded region is captured</strong> by replacing all <code>&#39;O&#39;</code>s with <code>&#39;X&#39;</code>s in the input matrix <code>board</code>.</p>
81447+
<p>To capture a <strong>surrounded region</strong>, replace all <code>&#39;O&#39;</code>s with <code>&#39;X&#39;</code>s <strong>in-place</strong> within the original board. You do not need to return anything.</p>
8144881448

8144981449
<p>&nbsp;</p>
8145081450
<p><strong class="example">Example 1:</strong></p>

en/lc/2408/index.html

Lines changed: 135 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81421,61 +81421,165 @@ <h1 id="2408-design-sql"><a href="https://leetcode.com/problems/design-sql">2408
8142181421
<h2 id="description">Description</h2>
8142281422
<!-- description:start -->
8142381423

81424-
<p>You are given <code>n</code> tables represented with two arrays <code>names</code> and <code>columns</code>, where <code>names[i]</code> is the name of the <code>i<sup>th</sup></code> table and <code>columns[i]</code> is the number of columns of the <code>i<sup>th</sup></code> table.</p>
81424+
<p>You are given two string arrays, <code>names</code> and <code>columns</code>, both of size <code>n</code>. The <code>i<sup>th</sup></code> table is represented by the name <code>names[i]</code> and contains <code>columns[i]</code> number of columns.</p>
8142581425

81426-
<p>You should be able to perform the following <strong>operations</strong>:</p>
81426+
<p>You need to implement a class that supports the following <strong>operations</strong>:</p>
8142781427

8142881428
<ul>
81429-
<li><strong>Insert</strong> a row in a specific table. Each row you insert has an id. The id is assigned using an auto-increment method where the id of the first inserted row is 1, and the id of each other row inserted into the same table is the id of the last inserted row (even if it was deleted) plus one.</li>
81430-
<li><strong>Delete</strong> a row from a specific table. <strong>Note</strong> that deleting a row does not affect the id of the next inserted row.</li>
81429+
<li><strong>Insert</strong> a row in a specific table with an id assigned using an <em>auto-increment</em> method, where the id of the first inserted row is 1, and the id of each <em>new </em>row inserted into the same table is <strong>one greater</strong> than the id of the <strong>last inserted</strong> row, even if the last row was <em>removed</em>.</li>
81430+
<li><strong>Remove</strong> a row from a specific table. Removing a row <strong>does not</strong> affect the id of the next inserted row.</li>
8143181431
<li><strong>Select</strong> a specific cell from any table and return its value.</li>
81432+
<li><strong>Export</strong> all rows from any table in csv format.</li>
8143281433
</ul>
8143381434

8143481435
<p>Implement the <code>SQL</code> class:</p>
8143581436

8143681437
<ul>
81437-
<li><code>SQL(String[] names, int[] columns)</code> Creates the <code>n</code> tables.</li>
81438-
<li><code>void insertRow(String name, String[] row)</code> Adds a row to the table <code>name</code>. It is <strong>guaranteed</strong> that the table will exist, and the size of the array <code>row</code> is equal to the number of columns in the table.</li>
81439-
<li><code>void deleteRow(String name, int rowId)</code> Removes the row <code>rowId</code> from the table <code>name</code>. It is <strong>guaranteed</strong> that the table and row will <strong>exist</strong>.</li>
81440-
<li><code>String selectCell(String name, int rowId, int columnId)</code> Returns the value of the cell in the row <code>rowId</code> and the column <code>columnId</code> from the table <code>name</code>.</li>
81438+
<li><code>SQL(String[] names, int[] columns)</code>
81439+
81440+
<ul>
81441+
<li>Creates the <code>n</code> tables.</li>
81442+
</ul>
81443+
</li>
81444+
<li><code>bool ins(String name, String[] row)</code>
81445+
<ul>
81446+
<li>Inserts <code>row</code> into the table <code>name</code> and returns <code>true</code>.</li>
81447+
<li>If <code>row.length</code> <strong>does not</strong> match the expected number of columns, or <code>name</code> is <strong>not</strong> a valid table, returns <code>false</code> without any insertion.</li>
81448+
</ul>
81449+
</li>
81450+
<li><code>void rmv(String name, int rowId)</code>
81451+
<ul>
81452+
<li>Removes the row <code>rowId</code> from the table <code>name</code>.</li>
81453+
<li>If <code>name</code> is <strong>not</strong> a valid table or there is no row with id <code>rowId</code>, no removal is performed.</li>
81454+
</ul>
81455+
</li>
81456+
<li><code>String sel(String name, int rowId, int columnId)</code>
81457+
<ul>
81458+
<li>Returns the value of the cell at the specified <code>rowId</code> and <code>columnId</code> in the table <code>name</code>.</li>
81459+
<li>If <code>name</code> is <strong>not</strong> a valid table, or the cell <code>(rowId, columnId)</code> is <strong>invalid</strong>, returns <code>&quot;&lt;null&gt;&quot;</code>.</li>
81460+
</ul>
81461+
</li>
81462+
<li><code>String[] exp(String name)</code>
81463+
<ul>
81464+
<li>Returns the rows present in the table <code>name</code>.</li>
81465+
<li>If name is <strong>not</strong> a valid table, returns an empty array. Each row is represented as a string, with each cell value (<strong>including</strong> the row&#39;s id) separated by a <code>&quot;,&quot;</code>.</li>
81466+
</ul>
81467+
</li>
81468+
8144181469
</ul>
8144281470

8144381471
<p>&nbsp;</p>
8144481472
<p><strong class="example">Example 1:</strong></p>
8144581473

81446-
<pre>
81447-
<strong>Input</strong>
81448-
[&quot;SQL&quot;, &quot;insertRow&quot;, &quot;selectCell&quot;, &quot;insertRow&quot;, &quot;deleteRow&quot;, &quot;selectCell&quot;]
81449-
[[[&quot;one&quot;, &quot;two&quot;, &quot;three&quot;], [2, 3, 1]], [&quot;two&quot;, [&quot;first&quot;, &quot;second&quot;, &quot;third&quot;]], [&quot;two&quot;, 1, 3], [&quot;two&quot;, [&quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;]], [&quot;two&quot;, 1], [&quot;two&quot;, 2, 2]]
81450-
<strong>Output</strong>
81451-
[null, null, &quot;third&quot;, null, null, &quot;fifth&quot;]
81452-
81453-
<strong>Explanation</strong>
81454-
SQL sql = new SQL([&quot;one&quot;, &quot;two&quot;, &quot;three&quot;], [2, 3, 1]); // creates three tables.
81455-
sql.insertRow(&quot;two&quot;, [&quot;first&quot;, &quot;second&quot;, &quot;third&quot;]); // adds a row to the table &quot;two&quot;. Its id is 1.
81456-
sql.selectCell(&quot;two&quot;, 1, 3); // return &quot;third&quot;, finds the value of the third column in the row with id 1 of the table &quot;two&quot;.
81457-
sql.insertRow(&quot;two&quot;, [&quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;]); // adds another row to the table &quot;two&quot;. Its id is 2.
81458-
sql.deleteRow(&quot;two&quot;, 1); // deletes the first row of the table &quot;two&quot;. Note that the second row will still have the id 2.
81459-
sql.selectCell(&quot;two&quot;, 2, 2); // return &quot;fifth&quot;, finds the value of the second column in the row with id 2 of the table &quot;two&quot;.
81474+
<div class="example-block">
81475+
<p><strong>Input:</strong></p>
81476+
81477+
<pre class="example-io">
81478+
[&quot;SQL&quot;,&quot;ins&quot;,&quot;sel&quot;,&quot;ins&quot;,&quot;exp&quot;,&quot;rmv&quot;,&quot;sel&quot;,&quot;exp&quot;]
81479+
[[[&quot;one&quot;,&quot;two&quot;,&quot;three&quot;],[2,3,1]],[&quot;two&quot;,[&quot;first&quot;,&quot;second&quot;,&quot;third&quot;]],[&quot;two&quot;,1,3],[&quot;two&quot;,[&quot;fourth&quot;,&quot;fifth&quot;,&quot;sixth&quot;]],[&quot;two&quot;],[&quot;two&quot;,1],[&quot;two&quot;,2,2],[&quot;two&quot;]]
81480+
</pre>
81481+
81482+
<p><strong>Output:</strong></p>
81483+
81484+
<pre class="example-io">
81485+
[null,true,&quot;third&quot;,true,[&quot;1,first,second,third&quot;,&quot;2,fourth,fifth,sixth&quot;],null,&quot;fifth&quot;,[&quot;2,fourth,fifth,sixth&quot;]]</pre>
81486+
81487+
<p><strong>Explanation:</strong></p>
81488+
81489+
<pre class="example-io">
81490+
// Creates three tables.
81491+
SQL sql = new SQL([&quot;one&quot;, &quot;two&quot;, &quot;three&quot;], [2, 3, 1]);
81492+
81493+
// Adds a row to the table &quot;two&quot; with id 1. Returns True.
81494+
sql.ins(&quot;two&quot;, [&quot;first&quot;, &quot;second&quot;, &quot;third&quot;]);
81495+
81496+
// Returns the value &quot;third&quot; from the third column
81497+
// in the row with id 1 of the table &quot;two&quot;.
81498+
sql.sel(&quot;two&quot;, 1, 3);
81499+
81500+
// Adds another row to the table &quot;two&quot; with id 2. Returns True.
81501+
sql.ins(&quot;two&quot;, [&quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;]);
81502+
81503+
// Exports the rows of the table &quot;two&quot;.
81504+
// Currently, the table has 2 rows with ids 1 and 2.
81505+
sql.exp(&quot;two&quot;);
81506+
81507+
// Removes the first row of the table &quot;two&quot;. Note that the second row
81508+
// will still have the id 2.
81509+
sql.rmv(&quot;two&quot;, 1);
81510+
81511+
// Returns the value &quot;fifth&quot; from the second column
81512+
// in the row with id 2 of the table &quot;two&quot;.
81513+
sql.sel(&quot;two&quot;, 2, 2);
81514+
81515+
// Exports the rows of the table &quot;two&quot;.
81516+
// Currently, the table has 1 row with id 2.
81517+
sql.exp(&quot;two&quot;);
81518+
</pre>
81519+
</div>
81520+
81521+
<p><strong class="example">Example 2:</strong></p>
81522+
81523+
<div class="example-block">
81524+
<p><strong>Input:</strong></p>
81525+
81526+
<pre class="example-io">
81527+
[&quot;SQL&quot;,&quot;ins&quot;,&quot;sel&quot;,&quot;rmv&quot;,&quot;sel&quot;,&quot;ins&quot;,&quot;ins&quot;]
81528+
[[[&quot;one&quot;,&quot;two&quot;,&quot;three&quot;],[2,3,1]],[&quot;two&quot;,[&quot;first&quot;,&quot;second&quot;,&quot;third&quot;]],[&quot;two&quot;,1,3],[&quot;two&quot;,1],[&quot;two&quot;,1,2],[&quot;two&quot;,[&quot;fourth&quot;,&quot;fifth&quot;]],[&quot;two&quot;,[&quot;fourth&quot;,&quot;fifth&quot;,&quot;sixth&quot;]]]
81529+
</pre>
81530+
81531+
<p><strong>Output:</strong></p>
81532+
81533+
<pre class="example-io">
81534+
[null,true,&quot;third&quot;,null,&quot;&lt;null&gt;&quot;,false,true]
8146081535
</pre>
8146181536

81537+
<p><strong>Explanation:</strong></p>
81538+
81539+
<pre class="example-io">
81540+
// Creates three tables.
81541+
SQL sQL = new SQL([&quot;one&quot;, &quot;two&quot;, &quot;three&quot;], [2, 3, 1]);
81542+
81543+
// Adds a row to the table &quot;two&quot; with id 1. Returns True.
81544+
sQL.ins(&quot;two&quot;, [&quot;first&quot;, &quot;second&quot;, &quot;third&quot;]);
81545+
81546+
// Returns the value &quot;third&quot; from the third column
81547+
// in the row with id 1 of the table &quot;two&quot;.
81548+
sQL.sel(&quot;two&quot;, 1, 3);
81549+
81550+
// Removes the first row of the table &quot;two&quot;.
81551+
sQL.rmv(&quot;two&quot;, 1);
81552+
81553+
// Returns &quot;&lt;null&gt;&quot; as the cell with id 1
81554+
// has been removed from table &quot;two&quot;.
81555+
sQL.sel(&quot;two&quot;, 1, 2);
81556+
81557+
// Returns False as number of columns are not correct.
81558+
sQL.ins(&quot;two&quot;, [&quot;fourth&quot;, &quot;fifth&quot;]);
81559+
81560+
// Adds a row to the table &quot;two&quot; with id 2. Returns True.
81561+
sQL.ins(&quot;two&quot;, [&quot;fourth&quot;, &quot;fifth&quot;, &quot;sixth&quot;]);
81562+
</pre>
81563+
</div>
81564+
8146281565
<p>&nbsp;</p>
8146381566
<p><strong>Constraints:</strong></p>
8146481567

8146581568
<ul>
8146681569
<li><code>n == names.length == columns.length</code></li>
8146781570
<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>
81468-
<li><code>1 &lt;= names[i].length, row[i].length, name.length &lt;= 20</code></li>
81469-
<li><code>names[i]</code>, <code>row[i]</code>, and <code>name</code> consist of lowercase English letters.</li>
81470-
<li><code>1 &lt;= columns[i] &lt;= 100</code></li>
81471-
<li>All the strings of <code>names</code> are <strong>distinct</strong>.</li>
81472-
<li><code>name</code> exists in the array <code>names</code>.</li>
81473-
<li><code>row.length</code> equals the number of columns in the chosen table.</li>
81474-
<li><code>rowId</code> and <code>columnId</code> will be valid.</li>
81475-
<li>At most <code>250</code> calls will be made to <code>insertRow</code> and <code>deleteRow</code>.</li>
81476-
<li>At most <code>10<sup>4</sup></code> calls will be made to <code>selectCell</code>.</li>
81571+
<li><code>1 &lt;= names[i].length, row[i].length, name.length &lt;= 10</code></li>
81572+
<li><code>names[i]</code>, <code>row[i]</code>, and <code>name</code> consist only of lowercase English letters.</li>
81573+
<li><code>1 &lt;= columns[i] &lt;= 10</code></li>
81574+
<li><code>1 &lt;= row.length &lt;= 10</code></li>
81575+
<li>All <code>names[i]</code> are <strong>distinct</strong>.</li>
81576+
<li>At most <code>2000</code> calls will be made to <code>ins</code> and <code>rmv</code>.</li>
81577+
<li>At most <code>10<sup>4</sup></code> calls will be made to <code>sel</code>.</li>
81578+
<li>At most <code>500</code> calls will be made to <code>exp</code>.</li>
8147781579
</ul>
8147881580

81581+
<p>&nbsp;</p>
81582+
<p><strong>Follow-up:</strong> Which approach would you choose if the table might become sparse due to many deletions, and why? Consider the impact on memory usage and performance.</p>
8147981583
<!-- description:end -->
8148081584

8148181585
<h2 id="solutions">Solutions</h2>

en/lc/2635/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81442,7 +81442,7 @@ <h2 id="description">Description</h2>
8144281442
<ul>
8144381443
<li><code>0 &lt;= arr.length &lt;= 1000</code></li>
8144481444
<li><code><font face="monospace">-10<sup>9</sup>&nbsp;&lt;= arr[i] &lt;= 10<sup>9</sup></font></code></li>
81445-
<li><code>fn</code> returns a number</li>
81445+
<li><code>fn</code> returns an integer.</li>
8144681446
</ul>
8144781447

8144881448
<!-- description:end -->

en/lc/2762/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81462,7 +81462,7 @@ <h2 id="description">Description</h2>
8146281462
Continuous subarray of size 1: [5], [4], [2], [4].
8146381463
Continuous subarray of size 2: [5,4], [4,2], [2,4].
8146481464
Continuous subarray of size 3: [4,2,4].
81465-
Thereare no subarrys of size 4.
81465+
There are no subarrys of size 4.
8146681466
Total continuous subarrays = 4 + 3 + 1 = 8.
8146781467
It can be shown that there are no more continuous subarrays.
8146881468
</pre>

0 commit comments

Comments
 (0)