<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Stack on Yu-Cheng's Notes</title><link>https://linkingmon.github.io/blog/tags/stack/</link><description>Recent content in Stack on Yu-Cheng's Notes</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Fri, 09 Jan 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://linkingmon.github.io/blog/tags/stack/index.xml" rel="self" type="application/rss+xml"/><item><title>LC 224 - Basic Calculator</title><link>https://linkingmon.github.io/blog/coding/lc-224/</link><pubDate>Fri, 09 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-224/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This problem is not hard but need to consider some special conditions.&lt;/p&gt;
&lt;p&gt;I found that actually we just need to trace the actual sign after removing the parantheses. For instance, &lt;code&gt;1-(2-(3+4))&lt;/code&gt; is equal to &lt;code&gt;1-2+3+4&lt;/code&gt;, so we need to buffer the current actual sign when we get the &lt;code&gt;(&lt;/code&gt;. In this case, we stack &lt;code&gt;-&lt;/code&gt; when getting the first &lt;code&gt;(&lt;/code&gt;, and when approaching the second &lt;code&gt;(&lt;/code&gt;, we know that it is negative outside, and this is negative so we need to invert the sign inside this parantheses, so stack &lt;code&gt;+&lt;/code&gt; inside. And the sign is removed after &lt;code&gt;)&lt;/code&gt; is encountered.&lt;/p&gt;</description></item></channel></rss>