<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://alan-pluto.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://alan-pluto.github.io/" rel="alternate" type="text/html" /><updated>2025-12-30T17:06:05+00:00</updated><id>https://alan-pluto.github.io/feed.xml</id><title type="html">Alan’s Blog</title><subtitle>Notes on security, cryptography and engineering</subtitle><author><name>Alan Pluto</name></author><entry><title type="html">PDF测试</title><link href="https://alan-pluto.github.io/blog/2025/12/19/PDFTest.html" rel="alternate" type="text/html" title="PDF测试" /><published>2025-12-19T00:00:00+00:00</published><updated>2025-12-19T00:00:00+00:00</updated><id>https://alan-pluto.github.io/blog/2025/12/19/PDFTest</id><content type="html" xml:base="https://alan-pluto.github.io/blog/2025/12/19/PDFTest.html"><![CDATA[<p><a href="/assets/pdf/随机波动率模型.pdf" target="_blank">
  点击查看完整 PDF
</a></p>]]></content><author><name>Alan Pluto</name></author><category term="Blog" /><category term="PDF" /><category term="Jekyll" /><category term="GitHub Pages" /><summary type="html"><![CDATA[测试PDF渲染功能。]]></summary></entry><entry><title type="html">Hello World</title><link href="https://alan-pluto.github.io/blog/2025/12/18/HelloWorld.html" rel="alternate" type="text/html" title="Hello World" /><published>2025-12-18T00:00:00+00:00</published><updated>2025-12-18T00:00:00+00:00</updated><id>https://alan-pluto.github.io/blog/2025/12/18/HelloWorld</id><content type="html" xml:base="https://alan-pluto.github.io/blog/2025/12/18/HelloWorld.html"><![CDATA[<p>这是我的第一篇文章。
欢迎来到我的博客！在这里，我将分享关于Jekyll和GitHub Pages的知识和经验。希望你喜欢这篇文章，并期待更多精彩内容的到来！</p>]]></content><author><name>Alan Pluto</name></author><category term="Blog" /><category term="Jekyll" /><category term="GitHub Pages" /><summary type="html"><![CDATA[这是我的第一篇文章。]]></summary></entry><entry><title type="html">两数之和</title><link href="https://alan-pluto.github.io/blog/2025/12/18/twoSum.html" rel="alternate" type="text/html" title="两数之和" /><published>2025-12-18T00:00:00+00:00</published><updated>2025-12-18T00:00:00+00:00</updated><id>https://alan-pluto.github.io/blog/2025/12/18/twoSum</id><content type="html" xml:base="https://alan-pluto.github.io/blog/2025/12/18/twoSum.html"><![CDATA[<h2 id="一题目描述">一、<a href="https://leetcode.cn/problems/two-sum/description/?envType=study-plan-v2&amp;envId=top-100-liked">题目描述</a></h2>

<p>给定一个整数数组 nums 和一个整数目标值 target，请你在该数组中找出 和为目标值 target  的那 两个 整数，并返回它们的数组下标。</p>

<p>你可以假设每种输入只会对应一个答案，并且你不能使用两次相同的元素。</p>

<p>你可以按任意顺序返回答案。</p>

<h2 id="二示例">二、示例</h2>

<p><strong>示例 1：</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>输入：nums = [2,7,11,15], target = 9
输出：[0,1]
解释：因为 nums[0] + nums[1] == 9 ，返回 [0, 1] 
</code></pre></div></div>

<p><strong>示例 2：</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>输入：nums = [3,2,4], target = 6
输出：[1,2]
</code></pre></div></div>

<p><strong>示例 3：</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>输入：nums = [3,3], target = 6
输出：[0,1]
</code></pre></div></div>

<h2 id="三算法思路">三、算法思路</h2>

<h3 id="1-暴力解法">1. 暴力解法</h3>
<p>遍历数组中的元素，对于数组中的每个元素 nums[i] ，遍历该元素之后的所有元素，查找是否符合 nums[i] + nums[j] == target。
时间复杂度为 $ O(n^2) $</p>

<h3 id="2--on-解法">2. ( O(n) )解法</h3>
<p>遍历数组中的元素，在hash表中查找target - nums[i] ，如果查到了，则返回，如果没有查到，则把当前元素添加到hash表中。
时间复杂度为  ( O(n) )</p>

<h2 id="四代码示例">四、代码示例</h2>

<h3 id="leetcode-模式">LeetCode 模式</h3>

<pre><code class="language-C++">class Solution {
public:
    vector&lt;int&gt; twoSum(vector&lt;int&gt;&amp; nums, int target) {
        unordered_map&lt;int,int&gt; hashmap;
        for(int i=0;i&lt;nums.size();i++){
            if(hashmap.find(target-nums[i])!=hashmap.end()){
                return {i,hashmap[target-nums[i]]};
            }else{
                hashmap[nums[i]]=i;
            }
        }
        return {};
    }
};
</code></pre>

<h3 id="acm-模式">ACM 模式</h3>

<pre><code class="language-C++">#include &lt;bits/stdc++.h&gt;
using namespace std;
int main(){
    int n, target;
    while(cin&gt;&gt;n&gt;&gt;target){
        vector&lt;int&gt; nums(n);
        for(int i=0; i&lt;n; i++){
            cin&gt;&gt;nums[i];
        }
        unordered_map&lt;int,int&gt; hashmap;
        for(int i=0;i&lt;nums.size();i++){
            if(hashmap.find(target-nums[i])!=hashmap.end()){
                cout&lt;&lt;"["&lt;&lt;i&lt;&lt;", "&lt;&lt;hashmap[target-nums[i]]&lt;&lt;"]"&lt;&lt;endl;
                return 0;
            }else{
                hashmap[nums[i]]=i;
            }
        }
        cout&lt;&lt;"[]"&lt;&lt;endl;
    }
    return 0;
}
</code></pre>]]></content><author><name>Alan Pluto</name></author><category term="Blog" /><category term="C++" /><category term="LeetCode" /><category term="Algorithm" /><summary type="html"><![CDATA[这是 LeetCode 两数之和问题的思路解析与代码实现。]]></summary></entry></feed>