<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Issues &#8211; Zhijun Chen</title>
	<atom:link href="https://zhijunchen.com/category/tech-issues/feed/" rel="self" type="application/rss+xml" />
	<link>https://zhijunchen.com</link>
	<description></description>
	<lastBuildDate>Fri, 07 Jun 2024 06:32:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.4</generator>

<image>
	<url>https://zhijunchen.com/wp-content/uploads/2021/03/cropped-my-site-icon-1-32x32.png</url>
	<title>Tech Issues &#8211; Zhijun Chen</title>
	<link>https://zhijunchen.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Find Single Number In An Array</title>
		<link>https://zhijunchen.com/find-single-number-in-an-array/</link>
		
		<dc:creator><![CDATA[Zhijun Chen]]></dc:creator>
		<pubDate>Thu, 29 Apr 2021 10:25:23 +0000</pubDate>
				<category><![CDATA[Tech Issues]]></category>
		<category><![CDATA[LeetCode]]></category>
		<guid isPermaLink="false">https://zhijunchen.com/?p=149</guid>

					<description><![CDATA[I came across the following array questions on LeetCode and was amazed by one of the solutions achieving a linear runtime complexity and without using extra memory. Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.]]></description>
										<content:encoded><![CDATA[
<p>I came across the following array questions on <a href="https://leetcode.com/" target="_blank" rel="noreferrer noopener">LeetCode</a> and was amazed by one of the solutions achieving a linear runtime complexity and without using extra memory. Declaration: I didn&#8217;t come up with the solution.</p>



<h2 class="wp-block-heading">Problem Statement</h2>



<p>Given a&nbsp;<strong>non-empty</strong>&nbsp;array of integers&nbsp;<code>nums</code>, every element appears&nbsp;<em>twice</em>&nbsp;except for one. Find that single one.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted"><strong>Input:</strong> nums = [2,2,1]
<strong>Output:</strong> 1</pre>



<p><strong>Example 2:</strong></p>



<pre class="wp-block-preformatted"><strong>Input:</strong> nums = [4,1,2,1,2]
<strong>Output:</strong> 4</pre>



<p><strong>Example 3:</strong></p>



<pre class="wp-block-preformatted"><strong>Input:</strong> nums = [1]
<strong>Output:</strong> 1</pre>



<p><strong>Constraints:</strong></p>



<ul>
<li><code>1 &lt;= nums.length &lt;= 3 * 10<sup>4</sup></code></li>



<li><code>-3 * 10<sup>4</sup> &lt;= nums[i] &lt;= 3 * 10<sup>4</sup></code></li>



<li>Each element in the array appears twice except for one element which appears only once.</li>
</ul>



<hr class="wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading">Solution: Bit Manipulation</h2>



<p><strong>Concept</strong></p>



<ul>
<li>If we take XOR of zero and some bit, it will return that bit
<ul>
<li>a ⊕ 0 = a</li>
</ul>
</li>



<li>If we take XOR of two same bits, it will return 0
<ul>
<li>0 ⊕ a = 0</li>
</ul>
</li>



<li>a ⊕ b ⊕ a = (a ⊕ a) ⊕ b = 0 ⊕ b = b</li>
</ul>



<p>So we can XOR all bits together to find the unique number. Here is the solution for Java: </p>



<pre class="wp-block-code"><code lang="java" class="language-java">class Solution {
  public int singleNumber(int[] nums) {
    int a = 0;
    for (int i : nums) {
      a ^= i;
    }
    return a;
  }
}</code></pre>



<p><strong>Complexity Analysis</strong></p>



<ul>
<li>Time complexity : O(n). We only iterate through nums, so the time complexity is the number of elements in nums.</li>



<li>Space complexity : O(1).</li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Fix Signature Invalid Issue from packages.sury.org</title>
		<link>https://zhijunchen.com/fix-signature-invalid-issue-from-packages-sury-org/</link>
		
		<dc:creator><![CDATA[Zhijun Chen]]></dc:creator>
		<pubDate>Thu, 01 Apr 2021 09:23:01 +0000</pubDate>
				<category><![CDATA[Tech Issues]]></category>
		<category><![CDATA[Debian]]></category>
		<guid isPermaLink="false">https://zhijunchen.com/?p=71</guid>

					<description><![CDATA[I came across signature invalid error when trying to update Debian packages from packages.sury.org. It turned out to be a known expired key issue occurred recently. The following commands should fix it.]]></description>
										<content:encoded><![CDATA[
<p>I came across the following error when trying to update Debian packages.</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">*********@*******:~$ sudo apt-get update
...
Err:11 https://packages.sury.org/php stretch InRelease
  The following signatures were invalid: EXPKEYSIG B188E2B695BD4743 DEB.SURY.ORG Automatic Signing Key &lt;deb@sury.org&gt;
Get:15 https://packages.cloud.google.com/apt cloud-sdk/main amd64 Packages [154 kB]
Fetched 161 kB in 1s (134 kB/s)   
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files 
will be used. GPG error: https://packages.sury.org/php stretch InRelease: The following signatures were invalid: EX
PKEYSIG B188E2B695BD4743 DEB.SURY.ORG Automatic Signing Key &lt;deb@sury.org&gt;
W: Failed to fetch https://packages.sury.org/php/dists/stretch/InRelease  The following signatures were invalid: EX
PKEYSIG B188E2B695BD4743 DEB.SURY.ORG Automatic Signing Key &lt;deb@sury.org&gt;
W: Some index files failed to download. They have been ignored, or old ones used instead.</code></pre>



<p>It turned out to be a <a rel="noreferrer noopener" href="https://github.com/oerdnj/deb.sury.org/issues/1575" target="_blank">known expired key issue</a> occurred recently. The following commands should fix it.</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo apt-key del B188E2B695BD4743
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg</code></pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
