This commit is contained in:
krahets 2023-09-13 03:40:47 +08:00
parent 0ecd889943
commit 7d21ec9b82
9 changed files with 182 additions and 172 deletions

View file

@ -5324,48 +5324,52 @@
<a id="__codelineno-82-58" name="__codelineno-82-58" href="#__codelineno-82-58"></a><span class="cm">/* 中间插入元素 */</span> <a id="__codelineno-82-58" name="__codelineno-82-58" href="#__codelineno-82-58"></a><span class="cm">/* 中间插入元素 */</span>
<a id="__codelineno-82-59" name="__codelineno-82-59" href="#__codelineno-82-59"></a><span class="kt">void</span><span class="w"> </span><span class="nf">insert</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">num</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-82-59" name="__codelineno-82-59" href="#__codelineno-82-59"></a><span class="kt">void</span><span class="w"> </span><span class="nf">insert</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">num</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-60" name="__codelineno-82-60" href="#__codelineno-82-60"></a><span class="w"> </span><span class="n">assert</span><span class="p">(</span><span class="n">index</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">index</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">));</span> <a id="__codelineno-82-60" name="__codelineno-82-60" href="#__codelineno-82-60"></a><span class="w"> </span><span class="n">assert</span><span class="p">(</span><span class="n">index</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">index</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">));</span>
<a id="__codelineno-82-61" name="__codelineno-82-61" href="#__codelineno-82-61"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">);</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="n">index</span><span class="p">;</span><span class="w"> </span><span class="o">--</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-82-61" name="__codelineno-82-61" href="#__codelineno-82-61"></a><span class="w"> </span><span class="c1">// 元素数量超出容量时,触发扩容机制</span>
<a id="__codelineno-82-62" name="__codelineno-82-62" href="#__codelineno-82-62"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">];</span> <a id="__codelineno-82-62" name="__codelineno-82-62" href="#__codelineno-82-62"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">capacity</span><span class="p">(</span><span class="n">list</span><span class="p">))</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-63" name="__codelineno-82-63" href="#__codelineno-82-63"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-82-63" name="__codelineno-82-63" href="#__codelineno-82-63"></a><span class="w"> </span><span class="n">extendCapacity</span><span class="p">(</span><span class="n">list</span><span class="p">);</span><span class="w"> </span><span class="c1">// 扩容</span>
<a id="__codelineno-82-64" name="__codelineno-82-64" href="#__codelineno-82-64"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">index</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">num</span><span class="p">;</span> <a id="__codelineno-82-64" name="__codelineno-82-64" href="#__codelineno-82-64"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-82-65" name="__codelineno-82-65" href="#__codelineno-82-65"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">size</span><span class="o">++</span><span class="p">;</span> <a id="__codelineno-82-65" name="__codelineno-82-65" href="#__codelineno-82-65"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">);</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="n">index</span><span class="p">;</span><span class="w"> </span><span class="o">--</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-66" name="__codelineno-82-66" href="#__codelineno-82-66"></a><span class="p">}</span> <a id="__codelineno-82-66" name="__codelineno-82-66" href="#__codelineno-82-66"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">];</span>
<a id="__codelineno-82-67" name="__codelineno-82-67" href="#__codelineno-82-67"></a> <a id="__codelineno-82-67" name="__codelineno-82-67" href="#__codelineno-82-67"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-82-68" name="__codelineno-82-68" href="#__codelineno-82-68"></a><span class="cm">/* 删除元素 */</span> <a id="__codelineno-82-68" name="__codelineno-82-68" href="#__codelineno-82-68"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">index</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">num</span><span class="p">;</span>
<a id="__codelineno-82-69" name="__codelineno-82-69" href="#__codelineno-82-69"></a><span class="c1">// 注意stdio.h 占用了 remove 关键词</span> <a id="__codelineno-82-69" name="__codelineno-82-69" href="#__codelineno-82-69"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">size</span><span class="o">++</span><span class="p">;</span>
<a id="__codelineno-82-70" name="__codelineno-82-70" href="#__codelineno-82-70"></a><span class="kt">int</span><span class="w"> </span><span class="nf">removeNum</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-82-70" name="__codelineno-82-70" href="#__codelineno-82-70"></a><span class="p">}</span>
<a id="__codelineno-82-71" name="__codelineno-82-71" href="#__codelineno-82-71"></a><span class="w"> </span><span class="n">assert</span><span class="p">(</span><span class="n">index</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">index</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">));</span> <a id="__codelineno-82-71" name="__codelineno-82-71" href="#__codelineno-82-71"></a>
<a id="__codelineno-82-72" name="__codelineno-82-72" href="#__codelineno-82-72"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">num</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">index</span><span class="p">];</span> <a id="__codelineno-82-72" name="__codelineno-82-72" href="#__codelineno-82-72"></a><span class="cm">/* 删除元素 */</span>
<a id="__codelineno-82-73" name="__codelineno-82-73" href="#__codelineno-82-73"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">index</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-82-73" name="__codelineno-82-73" href="#__codelineno-82-73"></a><span class="c1">// 注意stdio.h 占用了 remove 关键词</span>
<a id="__codelineno-82-74" name="__codelineno-82-74" href="#__codelineno-82-74"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">];</span> <a id="__codelineno-82-74" name="__codelineno-82-74" href="#__codelineno-82-74"></a><span class="kt">int</span><span class="w"> </span><span class="nf">removeNum</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-75" name="__codelineno-82-75" href="#__codelineno-82-75"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-82-75" name="__codelineno-82-75" href="#__codelineno-82-75"></a><span class="w"> </span><span class="n">assert</span><span class="p">(</span><span class="n">index</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">index</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">));</span>
<a id="__codelineno-82-76" name="__codelineno-82-76" href="#__codelineno-82-76"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">size</span><span class="o">--</span><span class="p">;</span> <a id="__codelineno-82-76" name="__codelineno-82-76" href="#__codelineno-82-76"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">num</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">index</span><span class="p">];</span>
<a id="__codelineno-82-77" name="__codelineno-82-77" href="#__codelineno-82-77"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">num</span><span class="p">;</span> <a id="__codelineno-82-77" name="__codelineno-82-77" href="#__codelineno-82-77"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">index</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-78" name="__codelineno-82-78" href="#__codelineno-82-78"></a><span class="p">}</span> <a id="__codelineno-82-78" name="__codelineno-82-78" href="#__codelineno-82-78"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">];</span>
<a id="__codelineno-82-79" name="__codelineno-82-79" href="#__codelineno-82-79"></a> <a id="__codelineno-82-79" name="__codelineno-82-79" href="#__codelineno-82-79"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-82-80" name="__codelineno-82-80" href="#__codelineno-82-80"></a><span class="cm">/* 列表扩容 */</span> <a id="__codelineno-82-80" name="__codelineno-82-80" href="#__codelineno-82-80"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">size</span><span class="o">--</span><span class="p">;</span>
<a id="__codelineno-82-81" name="__codelineno-82-81" href="#__codelineno-82-81"></a><span class="kt">void</span><span class="w"> </span><span class="nf">extendCapacity</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-82-81" name="__codelineno-82-81" href="#__codelineno-82-81"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">num</span><span class="p">;</span>
<a id="__codelineno-82-82" name="__codelineno-82-82" href="#__codelineno-82-82"></a><span class="w"> </span><span class="c1">// 先分配空间</span> <a id="__codelineno-82-82" name="__codelineno-82-82" href="#__codelineno-82-82"></a><span class="p">}</span>
<a id="__codelineno-82-83" name="__codelineno-82-83" href="#__codelineno-82-83"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">newCapacity</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">capacity</span><span class="p">(</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">extendRatio</span><span class="p">;</span> <a id="__codelineno-82-83" name="__codelineno-82-83" href="#__codelineno-82-83"></a>
<a id="__codelineno-82-84" name="__codelineno-82-84" href="#__codelineno-82-84"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">extend</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="n">malloc</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">newCapacity</span><span class="p">);</span> <a id="__codelineno-82-84" name="__codelineno-82-84" href="#__codelineno-82-84"></a><span class="cm">/* 列表扩容 */</span>
<a id="__codelineno-82-85" name="__codelineno-82-85" href="#__codelineno-82-85"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">temp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">;</span> <a id="__codelineno-82-85" name="__codelineno-82-85" href="#__codelineno-82-85"></a><span class="kt">void</span><span class="w"> </span><span class="nf">extendCapacity</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-86" name="__codelineno-82-86" href="#__codelineno-82-86"></a> <a id="__codelineno-82-86" name="__codelineno-82-86" href="#__codelineno-82-86"></a><span class="w"> </span><span class="c1">// 先分配空间</span>
<a id="__codelineno-82-87" name="__codelineno-82-87" href="#__codelineno-82-87"></a><span class="w"> </span><span class="c1">// 拷贝旧数据到新数据</span> <a id="__codelineno-82-87" name="__codelineno-82-87" href="#__codelineno-82-87"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">newCapacity</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">capacity</span><span class="p">(</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">extendRatio</span><span class="p">;</span>
<a id="__codelineno-82-88" name="__codelineno-82-88" href="#__codelineno-82-88"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">);</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span> <a id="__codelineno-82-88" name="__codelineno-82-88" href="#__codelineno-82-88"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">extend</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="p">)</span><span class="n">malloc</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">newCapacity</span><span class="p">);</span>
<a id="__codelineno-82-89" name="__codelineno-82-89" href="#__codelineno-82-89"></a><span class="w"> </span><span class="n">extend</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="p">];</span> <a id="__codelineno-82-89" name="__codelineno-82-89" href="#__codelineno-82-89"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">temp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">;</span>
<a id="__codelineno-82-90" name="__codelineno-82-90" href="#__codelineno-82-90"></a> <a id="__codelineno-82-90" name="__codelineno-82-90" href="#__codelineno-82-90"></a>
<a id="__codelineno-82-91" name="__codelineno-82-91" href="#__codelineno-82-91"></a><span class="w"> </span><span class="c1">// 释放旧数据</span> <a id="__codelineno-82-91" name="__codelineno-82-91" href="#__codelineno-82-91"></a><span class="w"> </span><span class="c1">// 拷贝旧数据到新数据</span>
<a id="__codelineno-82-92" name="__codelineno-82-92" href="#__codelineno-82-92"></a><span class="w"> </span><span class="n">free</span><span class="p">(</span><span class="n">temp</span><span class="p">);</span> <a id="__codelineno-82-92" name="__codelineno-82-92" href="#__codelineno-82-92"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">list</span><span class="p">);</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span>
<a id="__codelineno-82-93" name="__codelineno-82-93" href="#__codelineno-82-93"></a> <a id="__codelineno-82-93" name="__codelineno-82-93" href="#__codelineno-82-93"></a><span class="w"> </span><span class="n">extend</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
<a id="__codelineno-82-94" name="__codelineno-82-94" href="#__codelineno-82-94"></a><span class="w"> </span><span class="c1">// 更新新数据</span> <a id="__codelineno-82-94" name="__codelineno-82-94" href="#__codelineno-82-94"></a>
<a id="__codelineno-82-95" name="__codelineno-82-95" href="#__codelineno-82-95"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">extend</span><span class="p">;</span> <a id="__codelineno-82-95" name="__codelineno-82-95" href="#__codelineno-82-95"></a><span class="w"> </span><span class="c1">// 释放旧数据</span>
<a id="__codelineno-82-96" name="__codelineno-82-96" href="#__codelineno-82-96"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">capacity</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">newCapacity</span><span class="p">;</span> <a id="__codelineno-82-96" name="__codelineno-82-96" href="#__codelineno-82-96"></a><span class="w"> </span><span class="n">free</span><span class="p">(</span><span class="n">temp</span><span class="p">);</span>
<a id="__codelineno-82-97" name="__codelineno-82-97" href="#__codelineno-82-97"></a><span class="p">}</span> <a id="__codelineno-82-97" name="__codelineno-82-97" href="#__codelineno-82-97"></a>
<a id="__codelineno-82-98" name="__codelineno-82-98" href="#__codelineno-82-98"></a> <a id="__codelineno-82-98" name="__codelineno-82-98" href="#__codelineno-82-98"></a><span class="w"> </span><span class="c1">// 更新新数据</span>
<a id="__codelineno-82-99" name="__codelineno-82-99" href="#__codelineno-82-99"></a><span class="cm">/* 将列表转换为 Array 用于打印 */</span> <a id="__codelineno-82-99" name="__codelineno-82-99" href="#__codelineno-82-99"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">extend</span><span class="p">;</span>
<a id="__codelineno-82-100" name="__codelineno-82-100" href="#__codelineno-82-100"></a><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="nf">toArray</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-82-100" name="__codelineno-82-100" href="#__codelineno-82-100"></a><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">capacity</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">newCapacity</span><span class="p">;</span>
<a id="__codelineno-82-101" name="__codelineno-82-101" href="#__codelineno-82-101"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">;</span> <a id="__codelineno-82-101" name="__codelineno-82-101" href="#__codelineno-82-101"></a><span class="p">}</span>
<a id="__codelineno-82-102" name="__codelineno-82-102" href="#__codelineno-82-102"></a><span class="p">}</span> <a id="__codelineno-82-102" name="__codelineno-82-102" href="#__codelineno-82-102"></a>
<a id="__codelineno-82-103" name="__codelineno-82-103" href="#__codelineno-82-103"></a><span class="cm">/* 将列表转换为 Array 用于打印 */</span>
<a id="__codelineno-82-104" name="__codelineno-82-104" href="#__codelineno-82-104"></a><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="nf">toArray</span><span class="p">(</span><span class="n">myList</span><span class="w"> </span><span class="o">*</span><span class="n">list</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-82-105" name="__codelineno-82-105" href="#__codelineno-82-105"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">list</span><span class="o">-&gt;</span><span class="n">nums</span><span class="p">;</span>
<a id="__codelineno-82-106" name="__codelineno-82-106" href="#__codelineno-82-106"></a><span class="p">}</span>
</code></pre></div> </code></pre></div>
</div> </div>
<div class="tabbed-block"> <div class="tabbed-block">

View file

@ -3703,7 +3703,7 @@
<a id="__codelineno-10-2" name="__codelineno-10-2" href="#__codelineno-10-2"></a><span class="kt">int</span><span class="w"> </span><span class="nf">forLoop</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-10-2" name="__codelineno-10-2" href="#__codelineno-10-2"></a><span class="kt">int</span><span class="w"> </span><span class="nf">forLoop</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-10-3" name="__codelineno-10-3" href="#__codelineno-10-3"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span> <a id="__codelineno-10-3" name="__codelineno-10-3" href="#__codelineno-10-3"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<a id="__codelineno-10-4" name="__codelineno-10-4" href="#__codelineno-10-4"></a><span class="w"> </span><span class="c1">// 循环求和 1, 2, ..., n-1, n</span> <a id="__codelineno-10-4" name="__codelineno-10-4" href="#__codelineno-10-4"></a><span class="w"> </span><span class="c1">// 循环求和 1, 2, ..., n-1, n</span>
<a id="__codelineno-10-5" name="__codelineno-10-5" href="#__codelineno-10-5"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-10-5" name="__codelineno-10-5" href="#__codelineno-10-5"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-10-6" name="__codelineno-10-6" href="#__codelineno-10-6"></a><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span> <a id="__codelineno-10-6" name="__codelineno-10-6" href="#__codelineno-10-6"></a><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<a id="__codelineno-10-7" name="__codelineno-10-7" href="#__codelineno-10-7"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-10-7" name="__codelineno-10-7" href="#__codelineno-10-7"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-10-8" name="__codelineno-10-8" href="#__codelineno-10-8"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">res</span><span class="p">;</span> <a id="__codelineno-10-8" name="__codelineno-10-8" href="#__codelineno-10-8"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">res</span><span class="p">;</span>
@ -3944,9 +3944,9 @@
<a id="__codelineno-27-5" name="__codelineno-27-5" href="#__codelineno-27-5"></a><span class="w"> </span><span class="c1">// 循环求和 1, 2, 4, 5...</span> <a id="__codelineno-27-5" name="__codelineno-27-5" href="#__codelineno-27-5"></a><span class="w"> </span><span class="c1">// 循环求和 1, 2, 4, 5...</span>
<a id="__codelineno-27-6" name="__codelineno-27-6" href="#__codelineno-27-6"></a><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-27-6" name="__codelineno-27-6" href="#__codelineno-27-6"></a><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-27-7" name="__codelineno-27-7" href="#__codelineno-27-7"></a><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span> <a id="__codelineno-27-7" name="__codelineno-27-7" href="#__codelineno-27-7"></a><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span>
<a id="__codelineno-27-8" name="__codelineno-27-8" href="#__codelineno-27-8"></a><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="m">1</span><span class="p">;</span><span class="w"> </span><span class="c1">// 更新条件变量</span> <a id="__codelineno-27-8" name="__codelineno-27-8" href="#__codelineno-27-8"></a><span class="w"> </span><span class="c1">// 更新条件变量</span>
<a id="__codelineno-27-9" name="__codelineno-27-9" href="#__codelineno-27-9"></a><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">i</span><span class="p">;</span> <a id="__codelineno-27-9" name="__codelineno-27-9" href="#__codelineno-27-9"></a><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="m">1</span><span class="p">;</span><span class="w"> </span>
<a id="__codelineno-27-10" name="__codelineno-27-10" href="#__codelineno-27-10"></a><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">*=</span><span class="w"> </span><span class="m">2</span><span class="p">;</span><span class="w"> </span><span class="c1">// 更新条件变量</span> <a id="__codelineno-27-10" name="__codelineno-27-10" href="#__codelineno-27-10"></a><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">*=</span><span class="w"> </span><span class="m">2</span><span class="p">;</span>
<a id="__codelineno-27-11" name="__codelineno-27-11" href="#__codelineno-27-11"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-27-11" name="__codelineno-27-11" href="#__codelineno-27-11"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-27-12" name="__codelineno-27-12" href="#__codelineno-27-12"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">res</span><span class="p">;</span> <a id="__codelineno-27-12" name="__codelineno-27-12" href="#__codelineno-27-12"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">res</span><span class="p">;</span>
<a id="__codelineno-27-13" name="__codelineno-27-13" href="#__codelineno-27-13"></a><span class="p">}</span> <a id="__codelineno-27-13" name="__codelineno-27-13" href="#__codelineno-27-13"></a><span class="p">}</span>
@ -4229,18 +4229,17 @@
<a id="__codelineno-46-3" name="__codelineno-46-3" href="#__codelineno-46-3"></a><span class="w"> </span><span class="c1">// n * n 为对应点数量,&quot;(i, j), &quot; 对应字符串长最大为 6+10*2加上最后一个空字符 \0 的额外空间</span> <a id="__codelineno-46-3" name="__codelineno-46-3" href="#__codelineno-46-3"></a><span class="w"> </span><span class="c1">// n * n 为对应点数量,&quot;(i, j), &quot; 对应字符串长最大为 6+10*2加上最后一个空字符 \0 的额外空间</span>
<a id="__codelineno-46-4" name="__codelineno-46-4" href="#__codelineno-46-4"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">26</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span> <a id="__codelineno-46-4" name="__codelineno-46-4" href="#__codelineno-46-4"></a><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">26</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span>
<a id="__codelineno-46-5" name="__codelineno-46-5" href="#__codelineno-46-5"></a><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">malloc</span><span class="p">(</span><span class="n">size</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="kt">char</span><span class="p">));</span> <a id="__codelineno-46-5" name="__codelineno-46-5" href="#__codelineno-46-5"></a><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">malloc</span><span class="p">(</span><span class="n">size</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="kt">char</span><span class="p">));</span>
<a id="__codelineno-46-6" name="__codelineno-46-6" href="#__codelineno-46-6"></a> <a id="__codelineno-46-6" name="__codelineno-46-6" href="#__codelineno-46-6"></a><span class="w"> </span><span class="c1">// 循环 i = 1, 2, ..., n-1, n</span>
<a id="__codelineno-46-7" name="__codelineno-46-7" href="#__codelineno-46-7"></a><span class="w"> </span><span class="c1">// 循环 i = 1, 2, ..., n-1, n</span> <a id="__codelineno-46-7" name="__codelineno-46-7" href="#__codelineno-46-7"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-46-8" name="__codelineno-46-8" href="#__codelineno-46-8"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-46-8" name="__codelineno-46-8" href="#__codelineno-46-8"></a><span class="w"> </span><span class="c1">// 循环 j = 1, 2, ..., n-1, n</span>
<a id="__codelineno-46-9" name="__codelineno-46-9" href="#__codelineno-46-9"></a><span class="w"> </span><span class="c1">// 循环 j = 1, 2, ..., n-1, n</span> <a id="__codelineno-46-9" name="__codelineno-46-9" href="#__codelineno-46-9"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-46-10" name="__codelineno-46-10" href="#__codelineno-46-10"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="p">;</span><span class="w"> </span><span class="o">++</span><span class="n">j</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-46-10" name="__codelineno-46-10" href="#__codelineno-46-10"></a><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">tmp</span><span class="p">[</span><span class="mi">26</span><span class="p">];</span>
<a id="__codelineno-46-11" name="__codelineno-46-11" href="#__codelineno-46-11"></a><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">tmp</span><span class="p">[</span><span class="mi">26</span><span class="p">];</span> <a id="__codelineno-46-11" name="__codelineno-46-11" href="#__codelineno-46-11"></a><span class="w"> </span><span class="n">snprintf</span><span class="p">(</span><span class="n">tmp</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">tmp</span><span class="p">),</span><span class="w"> </span><span class="s">&quot;(%d, %d), &quot;</span><span class="p">,</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">j</span><span class="p">);</span>
<a id="__codelineno-46-12" name="__codelineno-46-12" href="#__codelineno-46-12"></a><span class="w"> </span><span class="n">snprintf</span><span class="p">(</span><span class="n">tmp</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="n">tmp</span><span class="p">),</span><span class="w"> </span><span class="s">&quot;(%d, %d), &quot;</span><span class="p">,</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">j</span><span class="p">);</span> <a id="__codelineno-46-12" name="__codelineno-46-12" href="#__codelineno-46-12"></a><span class="w"> </span><span class="n">strncat</span><span class="p">(</span><span class="n">res</span><span class="p">,</span><span class="w"> </span><span class="n">tmp</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">strlen</span><span class="p">(</span><span class="n">res</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>
<a id="__codelineno-46-13" name="__codelineno-46-13" href="#__codelineno-46-13"></a><span class="w"> </span><span class="n">strncat</span><span class="p">(</span><span class="n">res</span><span class="p">,</span><span class="w"> </span><span class="n">tmp</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">strlen</span><span class="p">(</span><span class="n">res</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span> <a id="__codelineno-46-13" name="__codelineno-46-13" href="#__codelineno-46-13"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-46-14" name="__codelineno-46-14" href="#__codelineno-46-14"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-46-14" name="__codelineno-46-14" href="#__codelineno-46-14"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-46-15" name="__codelineno-46-15" href="#__codelineno-46-15"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-46-15" name="__codelineno-46-15" href="#__codelineno-46-15"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">res</span><span class="p">;</span>
<a id="__codelineno-46-16" name="__codelineno-46-16" href="#__codelineno-46-16"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">res</span><span class="p">;</span> <a id="__codelineno-46-16" name="__codelineno-46-16" href="#__codelineno-46-16"></a><span class="p">}</span>
<a id="__codelineno-46-17" name="__codelineno-46-17" href="#__codelineno-46-17"></a><span class="p">}</span>
</code></pre></div> </code></pre></div>
</div> </div>
<div class="tabbed-block"> <div class="tabbed-block">

View file

@ -3480,7 +3480,7 @@
<ul> <ul>
<li>数据结构是算法的基石。数据结构为算法提供了结构化存储的数据,以及用于操作数据的方法。</li> <li>数据结构是算法的基石。数据结构为算法提供了结构化存储的数据,以及用于操作数据的方法。</li>
<li>算法是数据结构发挥作用的舞台。数据结构本身仅存储数据信息,结合算法才能解决特定问题。</li> <li>算法是数据结构发挥作用的舞台。数据结构本身仅存储数据信息,结合算法才能解决特定问题。</li>
<li>算法通常可以基于不同的数据结构进行实现,并往往有对应最优的数据结构,最终执行效率可能相差很大。</li> <li>算法通常可以基于不同的数据结构进行实现,但执行效率可能相差很大,选择合适的数据结构是关键</li>
</ul> </ul>
<p><img alt="数据结构与算法的关系" src="../what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png" /></p> <p><img alt="数据结构与算法的关系" src="../what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png" /></p>
<p align="center"> 图 1-4 &nbsp; 数据结构与算法的关系 </p> <p align="center"> 图 1-4 &nbsp; 数据结构与算法的关系 </p>

View file

@ -3599,7 +3599,14 @@
</code></pre></div> </code></pre></div>
</div> </div>
<div class="tabbed-block"> <div class="tabbed-block">
<div class="highlight"><pre><span></span><code><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a> <div class="highlight"><pre><span></span><code><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a><span class="cm">/* 标题注释,用于标注函数、类、测试样例等 */</span>
<a id="__codelineno-9-2" name="__codelineno-9-2" href="#__codelineno-9-2"></a>
<a id="__codelineno-9-3" name="__codelineno-9-3" href="#__codelineno-9-3"></a><span class="c1">// 内容注释,用于详解代码</span>
<a id="__codelineno-9-4" name="__codelineno-9-4" href="#__codelineno-9-4"></a>
<a id="__codelineno-9-5" name="__codelineno-9-5" href="#__codelineno-9-5"></a><span class="sd">/**</span>
<a id="__codelineno-9-6" name="__codelineno-9-6" href="#__codelineno-9-6"></a><span class="sd"> * 多行</span>
<a id="__codelineno-9-7" name="__codelineno-9-7" href="#__codelineno-9-7"></a><span class="sd"> * 注释</span>
<a id="__codelineno-9-8" name="__codelineno-9-8" href="#__codelineno-9-8"></a><span class="sd"> */</span>
</code></pre></div> </code></pre></div>
</div> </div>
<div class="tabbed-block"> <div class="tabbed-block">

View file

@ -5109,7 +5109,7 @@
<a id="__codelineno-30-19" name="__codelineno-30-19" href="#__codelineno-30-19"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-19" name="__codelineno-30-19" href="#__codelineno-30-19"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-20" name="__codelineno-30-20" href="#__codelineno-30-20"></a> <a id="__codelineno-30-20" name="__codelineno-30-20" href="#__codelineno-30-20"></a>
<a id="__codelineno-30-21" name="__codelineno-30-21" href="#__codelineno-30-21"></a><span class="w"> </span><span class="cm">/* 判断队列是否为空 */</span> <a id="__codelineno-30-21" name="__codelineno-30-21" href="#__codelineno-30-21"></a><span class="w"> </span><span class="cm">/* 判断队列是否为空 */</span>
<a id="__codelineno-30-22" name="__codelineno-30-22" href="#__codelineno-30-22"></a><span class="w"> </span><span class="nx">empty</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-30-22" name="__codelineno-30-22" href="#__codelineno-30-22"></a><span class="w"> </span><span class="nx">isEmpty</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-30-23" name="__codelineno-30-23" href="#__codelineno-30-23"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">queSize</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> <a id="__codelineno-30-23" name="__codelineno-30-23" href="#__codelineno-30-23"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">queSize</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span>
<a id="__codelineno-30-24" name="__codelineno-30-24" href="#__codelineno-30-24"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-24" name="__codelineno-30-24" href="#__codelineno-30-24"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-25" name="__codelineno-30-25" href="#__codelineno-30-25"></a> <a id="__codelineno-30-25" name="__codelineno-30-25" href="#__codelineno-30-25"></a>
@ -5138,7 +5138,7 @@
<a id="__codelineno-30-48" name="__codelineno-30-48" href="#__codelineno-30-48"></a> <a id="__codelineno-30-48" name="__codelineno-30-48" href="#__codelineno-30-48"></a>
<a id="__codelineno-30-49" name="__codelineno-30-49" href="#__codelineno-30-49"></a><span class="w"> </span><span class="cm">/* 访问队首元素 */</span> <a id="__codelineno-30-49" name="__codelineno-30-49" href="#__codelineno-30-49"></a><span class="w"> </span><span class="cm">/* 访问队首元素 */</span>
<a id="__codelineno-30-50" name="__codelineno-30-50" href="#__codelineno-30-50"></a><span class="w"> </span><span class="nx">peek</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-30-50" name="__codelineno-30-50" href="#__codelineno-30-50"></a><span class="w"> </span><span class="nx">peek</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-30-51" name="__codelineno-30-51" href="#__codelineno-30-51"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">empty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;队列为空&#39;</span><span class="p">);</span> <a id="__codelineno-30-51" name="__codelineno-30-51" href="#__codelineno-30-51"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;队列为空&#39;</span><span class="p">);</span>
<a id="__codelineno-30-52" name="__codelineno-30-52" href="#__codelineno-30-52"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">nums</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">front</span><span class="p">];</span> <a id="__codelineno-30-52" name="__codelineno-30-52" href="#__codelineno-30-52"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">nums</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">front</span><span class="p">];</span>
<a id="__codelineno-30-53" name="__codelineno-30-53" href="#__codelineno-30-53"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-53" name="__codelineno-30-53" href="#__codelineno-30-53"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-54" name="__codelineno-30-54" href="#__codelineno-30-54"></a> <a id="__codelineno-30-54" name="__codelineno-30-54" href="#__codelineno-30-54"></a>
@ -5177,7 +5177,7 @@
<a id="__codelineno-31-20" name="__codelineno-31-20" href="#__codelineno-31-20"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-20" name="__codelineno-31-20" href="#__codelineno-31-20"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-21" name="__codelineno-31-21" href="#__codelineno-31-21"></a> <a id="__codelineno-31-21" name="__codelineno-31-21" href="#__codelineno-31-21"></a>
<a id="__codelineno-31-22" name="__codelineno-31-22" href="#__codelineno-31-22"></a><span class="w"> </span><span class="cm">/* 判断队列是否为空 */</span> <a id="__codelineno-31-22" name="__codelineno-31-22" href="#__codelineno-31-22"></a><span class="w"> </span><span class="cm">/* 判断队列是否为空 */</span>
<a id="__codelineno-31-23" name="__codelineno-31-23" href="#__codelineno-31-23"></a><span class="w"> </span><span class="nx">empty</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">boolean</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-31-23" name="__codelineno-31-23" href="#__codelineno-31-23"></a><span class="w"> </span><span class="nx">isEmpty</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">boolean</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-31-24" name="__codelineno-31-24" href="#__codelineno-31-24"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">queSize</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> <a id="__codelineno-31-24" name="__codelineno-31-24" href="#__codelineno-31-24"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">queSize</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span>
<a id="__codelineno-31-25" name="__codelineno-31-25" href="#__codelineno-31-25"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-25" name="__codelineno-31-25" href="#__codelineno-31-25"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-26" name="__codelineno-31-26" href="#__codelineno-31-26"></a> <a id="__codelineno-31-26" name="__codelineno-31-26" href="#__codelineno-31-26"></a>
@ -5206,7 +5206,7 @@
<a id="__codelineno-31-49" name="__codelineno-31-49" href="#__codelineno-31-49"></a> <a id="__codelineno-31-49" name="__codelineno-31-49" href="#__codelineno-31-49"></a>
<a id="__codelineno-31-50" name="__codelineno-31-50" href="#__codelineno-31-50"></a><span class="w"> </span><span class="cm">/* 访问队首元素 */</span> <a id="__codelineno-31-50" name="__codelineno-31-50" href="#__codelineno-31-50"></a><span class="w"> </span><span class="cm">/* 访问队首元素 */</span>
<a id="__codelineno-31-51" name="__codelineno-31-51" href="#__codelineno-31-51"></a><span class="w"> </span><span class="nx">peek</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">number</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-31-51" name="__codelineno-31-51" href="#__codelineno-31-51"></a><span class="w"> </span><span class="nx">peek</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">number</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-31-52" name="__codelineno-31-52" href="#__codelineno-31-52"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">empty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;队列为空&#39;</span><span class="p">);</span> <a id="__codelineno-31-52" name="__codelineno-31-52" href="#__codelineno-31-52"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;队列为空&#39;</span><span class="p">);</span>
<a id="__codelineno-31-53" name="__codelineno-31-53" href="#__codelineno-31-53"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">nums</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">front</span><span class="p">];</span> <a id="__codelineno-31-53" name="__codelineno-31-53" href="#__codelineno-31-53"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">nums</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">front</span><span class="p">];</span>
<a id="__codelineno-31-54" name="__codelineno-31-54" href="#__codelineno-31-54"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-54" name="__codelineno-31-54" href="#__codelineno-31-54"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-55" name="__codelineno-31-55" href="#__codelineno-31-55"></a> <a id="__codelineno-31-55" name="__codelineno-31-55" href="#__codelineno-31-55"></a>

View file

@ -4849,7 +4849,7 @@
<a id="__codelineno-30-11" name="__codelineno-30-11" href="#__codelineno-30-11"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-11" name="__codelineno-30-11" href="#__codelineno-30-11"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-12" name="__codelineno-30-12" href="#__codelineno-30-12"></a> <a id="__codelineno-30-12" name="__codelineno-30-12" href="#__codelineno-30-12"></a>
<a id="__codelineno-30-13" name="__codelineno-30-13" href="#__codelineno-30-13"></a><span class="w"> </span><span class="cm">/* 判断栈是否为空 */</span> <a id="__codelineno-30-13" name="__codelineno-30-13" href="#__codelineno-30-13"></a><span class="w"> </span><span class="cm">/* 判断栈是否为空 */</span>
<a id="__codelineno-30-14" name="__codelineno-30-14" href="#__codelineno-30-14"></a><span class="w"> </span><span class="nx">empty</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-30-14" name="__codelineno-30-14" href="#__codelineno-30-14"></a><span class="w"> </span><span class="nx">isEmpty</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-30-15" name="__codelineno-30-15" href="#__codelineno-30-15"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> <a id="__codelineno-30-15" name="__codelineno-30-15" href="#__codelineno-30-15"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span>
<a id="__codelineno-30-16" name="__codelineno-30-16" href="#__codelineno-30-16"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-16" name="__codelineno-30-16" href="#__codelineno-30-16"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-17" name="__codelineno-30-17" href="#__codelineno-30-17"></a> <a id="__codelineno-30-17" name="__codelineno-30-17" href="#__codelineno-30-17"></a>
@ -4860,13 +4860,13 @@
<a id="__codelineno-30-22" name="__codelineno-30-22" href="#__codelineno-30-22"></a> <a id="__codelineno-30-22" name="__codelineno-30-22" href="#__codelineno-30-22"></a>
<a id="__codelineno-30-23" name="__codelineno-30-23" href="#__codelineno-30-23"></a><span class="w"> </span><span class="cm">/* 出栈 */</span> <a id="__codelineno-30-23" name="__codelineno-30-23" href="#__codelineno-30-23"></a><span class="w"> </span><span class="cm">/* 出栈 */</span>
<a id="__codelineno-30-24" name="__codelineno-30-24" href="#__codelineno-30-24"></a><span class="w"> </span><span class="nx">pop</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-30-24" name="__codelineno-30-24" href="#__codelineno-30-24"></a><span class="w"> </span><span class="nx">pop</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-30-25" name="__codelineno-30-25" href="#__codelineno-30-25"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">empty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span> <a id="__codelineno-30-25" name="__codelineno-30-25" href="#__codelineno-30-25"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span>
<a id="__codelineno-30-26" name="__codelineno-30-26" href="#__codelineno-30-26"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span> <a id="__codelineno-30-26" name="__codelineno-30-26" href="#__codelineno-30-26"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span>
<a id="__codelineno-30-27" name="__codelineno-30-27" href="#__codelineno-30-27"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-27" name="__codelineno-30-27" href="#__codelineno-30-27"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-28" name="__codelineno-30-28" href="#__codelineno-30-28"></a> <a id="__codelineno-30-28" name="__codelineno-30-28" href="#__codelineno-30-28"></a>
<a id="__codelineno-30-29" name="__codelineno-30-29" href="#__codelineno-30-29"></a><span class="w"> </span><span class="cm">/* 访问栈顶元素 */</span> <a id="__codelineno-30-29" name="__codelineno-30-29" href="#__codelineno-30-29"></a><span class="w"> </span><span class="cm">/* 访问栈顶元素 */</span>
<a id="__codelineno-30-30" name="__codelineno-30-30" href="#__codelineno-30-30"></a><span class="w"> </span><span class="nx">top</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-30-30" name="__codelineno-30-30" href="#__codelineno-30-30"></a><span class="w"> </span><span class="nx">top</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-30-31" name="__codelineno-30-31" href="#__codelineno-30-31"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">empty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span> <a id="__codelineno-30-31" name="__codelineno-30-31" href="#__codelineno-30-31"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span>
<a id="__codelineno-30-32" name="__codelineno-30-32" href="#__codelineno-30-32"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span> <a id="__codelineno-30-32" name="__codelineno-30-32" href="#__codelineno-30-32"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span>
<a id="__codelineno-30-33" name="__codelineno-30-33" href="#__codelineno-30-33"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-30-33" name="__codelineno-30-33" href="#__codelineno-30-33"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-30-34" name="__codelineno-30-34" href="#__codelineno-30-34"></a> <a id="__codelineno-30-34" name="__codelineno-30-34" href="#__codelineno-30-34"></a>
@ -4891,7 +4891,7 @@
<a id="__codelineno-31-11" name="__codelineno-31-11" href="#__codelineno-31-11"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-11" name="__codelineno-31-11" href="#__codelineno-31-11"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-12" name="__codelineno-31-12" href="#__codelineno-31-12"></a> <a id="__codelineno-31-12" name="__codelineno-31-12" href="#__codelineno-31-12"></a>
<a id="__codelineno-31-13" name="__codelineno-31-13" href="#__codelineno-31-13"></a><span class="w"> </span><span class="cm">/* 判断栈是否为空 */</span> <a id="__codelineno-31-13" name="__codelineno-31-13" href="#__codelineno-31-13"></a><span class="w"> </span><span class="cm">/* 判断栈是否为空 */</span>
<a id="__codelineno-31-14" name="__codelineno-31-14" href="#__codelineno-31-14"></a><span class="w"> </span><span class="nx">empty</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">boolean</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-31-14" name="__codelineno-31-14" href="#__codelineno-31-14"></a><span class="w"> </span><span class="nx">isEmpty</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">boolean</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-31-15" name="__codelineno-31-15" href="#__codelineno-31-15"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span> <a id="__codelineno-31-15" name="__codelineno-31-15" href="#__codelineno-31-15"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">===</span><span class="w"> </span><span class="mf">0</span><span class="p">;</span>
<a id="__codelineno-31-16" name="__codelineno-31-16" href="#__codelineno-31-16"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-16" name="__codelineno-31-16" href="#__codelineno-31-16"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-17" name="__codelineno-31-17" href="#__codelineno-31-17"></a> <a id="__codelineno-31-17" name="__codelineno-31-17" href="#__codelineno-31-17"></a>
@ -4902,13 +4902,13 @@
<a id="__codelineno-31-22" name="__codelineno-31-22" href="#__codelineno-31-22"></a> <a id="__codelineno-31-22" name="__codelineno-31-22" href="#__codelineno-31-22"></a>
<a id="__codelineno-31-23" name="__codelineno-31-23" href="#__codelineno-31-23"></a><span class="w"> </span><span class="cm">/* 出栈 */</span> <a id="__codelineno-31-23" name="__codelineno-31-23" href="#__codelineno-31-23"></a><span class="w"> </span><span class="cm">/* 出栈 */</span>
<a id="__codelineno-31-24" name="__codelineno-31-24" href="#__codelineno-31-24"></a><span class="w"> </span><span class="nx">pop</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">number</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="kc">undefined</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-31-24" name="__codelineno-31-24" href="#__codelineno-31-24"></a><span class="w"> </span><span class="nx">pop</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">number</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="kc">undefined</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-31-25" name="__codelineno-31-25" href="#__codelineno-31-25"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">empty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span> <a id="__codelineno-31-25" name="__codelineno-31-25" href="#__codelineno-31-25"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span>
<a id="__codelineno-31-26" name="__codelineno-31-26" href="#__codelineno-31-26"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span> <a id="__codelineno-31-26" name="__codelineno-31-26" href="#__codelineno-31-26"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span>
<a id="__codelineno-31-27" name="__codelineno-31-27" href="#__codelineno-31-27"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-27" name="__codelineno-31-27" href="#__codelineno-31-27"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-28" name="__codelineno-31-28" href="#__codelineno-31-28"></a> <a id="__codelineno-31-28" name="__codelineno-31-28" href="#__codelineno-31-28"></a>
<a id="__codelineno-31-29" name="__codelineno-31-29" href="#__codelineno-31-29"></a><span class="w"> </span><span class="cm">/* 访问栈顶元素 */</span> <a id="__codelineno-31-29" name="__codelineno-31-29" href="#__codelineno-31-29"></a><span class="w"> </span><span class="cm">/* 访问栈顶元素 */</span>
<a id="__codelineno-31-30" name="__codelineno-31-30" href="#__codelineno-31-30"></a><span class="w"> </span><span class="nx">top</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">number</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="kc">undefined</span><span class="w"> </span><span class="p">{</span> <a id="__codelineno-31-30" name="__codelineno-31-30" href="#__codelineno-31-30"></a><span class="w"> </span><span class="nx">top</span><span class="p">()</span><span class="o">:</span><span class="w"> </span><span class="kt">number</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="kc">undefined</span><span class="w"> </span><span class="p">{</span>
<a id="__codelineno-31-31" name="__codelineno-31-31" href="#__codelineno-31-31"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">empty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span> <a id="__codelineno-31-31" name="__codelineno-31-31" href="#__codelineno-31-31"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s1">&#39;栈为空&#39;</span><span class="p">);</span>
<a id="__codelineno-31-32" name="__codelineno-31-32" href="#__codelineno-31-32"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span> <a id="__codelineno-31-32" name="__codelineno-31-32" href="#__codelineno-31-32"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mf">1</span><span class="p">];</span>
<a id="__codelineno-31-33" name="__codelineno-31-33" href="#__codelineno-31-33"></a><span class="w"> </span><span class="p">}</span> <a id="__codelineno-31-33" name="__codelineno-31-33" href="#__codelineno-31-33"></a><span class="w"> </span><span class="p">}</span>
<a id="__codelineno-31-34" name="__codelineno-31-34" href="#__codelineno-31-34"></a> <a id="__codelineno-31-34" name="__codelineno-31-34" href="#__codelineno-31-34"></a>

File diff suppressed because one or more lines are too long

View file

@ -2,512 +2,512 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url> <url>
<loc>https://www.hello-algo.com/</loc> <loc>https://www.hello-algo.com/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_appendix/</loc> <loc>https://www.hello-algo.com/chapter_appendix/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc> <loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_appendix/installation/</loc> <loc>https://www.hello-algo.com/chapter_appendix/installation/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc> <loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_backtracking/</loc> <loc>https://www.hello-algo.com/chapter_backtracking/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_backtracking/backtracking_algorithm/</loc> <loc>https://www.hello-algo.com/chapter_backtracking/backtracking_algorithm/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_backtracking/n_queens_problem/</loc> <loc>https://www.hello-algo.com/chapter_backtracking/n_queens_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_backtracking/permutations_problem/</loc> <loc>https://www.hello-algo.com/chapter_backtracking/permutations_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_backtracking/subset_sum_problem/</loc> <loc>https://www.hello-algo.com/chapter_backtracking/subset_sum_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_backtracking/summary/</loc> <loc>https://www.hello-algo.com/chapter_backtracking/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/iteration_and_recursion/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/iteration_and_recursion/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc> <loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/basic_data_types/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/basic_data_types/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/character_encoding/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/character_encoding/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/number_encoding/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/number_encoding/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc> <loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_divide_and_conquer/</loc> <loc>https://www.hello-algo.com/chapter_divide_and_conquer/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_divide_and_conquer/binary_search_recur/</loc> <loc>https://www.hello-algo.com/chapter_divide_and_conquer/binary_search_recur/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_divide_and_conquer/build_binary_tree_problem/</loc> <loc>https://www.hello-algo.com/chapter_divide_and_conquer/build_binary_tree_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_divide_and_conquer/divide_and_conquer/</loc> <loc>https://www.hello-algo.com/chapter_divide_and_conquer/divide_and_conquer/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_divide_and_conquer/hanota_problem/</loc> <loc>https://www.hello-algo.com/chapter_divide_and_conquer/hanota_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_divide_and_conquer/summary/</loc> <loc>https://www.hello-algo.com/chapter_divide_and_conquer/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/dp_problem_features/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/dp_problem_features/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/dp_solution_pipeline/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/dp_solution_pipeline/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/edit_distance_problem/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/edit_distance_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/intro_to_dynamic_programming/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/intro_to_dynamic_programming/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/knapsack_problem/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/knapsack_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/summary/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_dynamic_programming/unbounded_knapsack_problem/</loc> <loc>https://www.hello-algo.com/chapter_dynamic_programming/unbounded_knapsack_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/</loc> <loc>https://www.hello-algo.com/chapter_graph/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/graph/</loc> <loc>https://www.hello-algo.com/chapter_graph/graph/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc> <loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc> <loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_graph/summary/</loc> <loc>https://www.hello-algo.com/chapter_graph/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_greedy/</loc> <loc>https://www.hello-algo.com/chapter_greedy/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_greedy/fractional_knapsack_problem/</loc> <loc>https://www.hello-algo.com/chapter_greedy/fractional_knapsack_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_greedy/greedy_algorithm/</loc> <loc>https://www.hello-algo.com/chapter_greedy/greedy_algorithm/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_greedy/max_capacity_problem/</loc> <loc>https://www.hello-algo.com/chapter_greedy/max_capacity_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_greedy/max_product_cutting_problem/</loc> <loc>https://www.hello-algo.com/chapter_greedy/max_product_cutting_problem/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_greedy/summary/</loc> <loc>https://www.hello-algo.com/chapter_greedy/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/</loc> <loc>https://www.hello-algo.com/chapter_hashing/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_algorithm/</loc> <loc>https://www.hello-algo.com/chapter_hashing/hash_algorithm/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc> <loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc> <loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_hashing/summary/</loc> <loc>https://www.hello-algo.com/chapter_hashing/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/</loc> <loc>https://www.hello-algo.com/chapter_heap/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc> <loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/heap/</loc> <loc>https://www.hello-algo.com/chapter_heap/heap/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/summary/</loc> <loc>https://www.hello-algo.com/chapter_heap/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_heap/top_k/</loc> <loc>https://www.hello-algo.com/chapter_heap/top_k/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/</loc> <loc>https://www.hello-algo.com/chapter_introduction/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc> <loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/summary/</loc> <loc>https://www.hello-algo.com/chapter_introduction/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc> <loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/</loc> <loc>https://www.hello-algo.com/chapter_preface/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc> <loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc> <loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_preface/summary/</loc> <loc>https://www.hello-algo.com/chapter_preface/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_reference/</loc> <loc>https://www.hello-algo.com/chapter_reference/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/</loc> <loc>https://www.hello-algo.com/chapter_searching/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc> <loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/binary_search_edge/</loc> <loc>https://www.hello-algo.com/chapter_searching/binary_search_edge/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/binary_search_insertion/</loc> <loc>https://www.hello-algo.com/chapter_searching/binary_search_insertion/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/replace_linear_by_hashing/</loc> <loc>https://www.hello-algo.com/chapter_searching/replace_linear_by_hashing/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/searching_algorithm_revisited/</loc> <loc>https://www.hello-algo.com/chapter_searching/searching_algorithm_revisited/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_searching/summary/</loc> <loc>https://www.hello-algo.com/chapter_searching/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/</loc> <loc>https://www.hello-algo.com/chapter_sorting/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/bucket_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/bucket_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/counting_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/counting_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/heap_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/heap_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/radix_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/radix_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/selection_sort/</loc> <loc>https://www.hello-algo.com/chapter_sorting/selection_sort/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/sorting_algorithm/</loc> <loc>https://www.hello-algo.com/chapter_sorting/sorting_algorithm/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_sorting/summary/</loc> <loc>https://www.hello-algo.com/chapter_sorting/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc> <loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/array_representation_of_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/array_representation_of_tree/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc> <loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc> <loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://www.hello-algo.com/chapter_tree/summary/</loc> <loc>https://www.hello-algo.com/chapter_tree/summary/</loc>
<lastmod>2023-09-11</lastmod> <lastmod>2023-09-12</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
</urlset> </urlset>

Binary file not shown.