<div dir="ltr"><div class="gmail_default" style="font-family:simsun,serif;font-size:small">Hi Swift-Users,</div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> when I compiled the code, Xcode cannot stop, I do not know why. It is very strange. Can anyone help ? Here is the code. I am using Xcode 8.1</div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small">
<p class="gmail-p1"><span class="gmail-s2">class</span><span class="gmail-s1"> Solution {</span><br><span class="gmail-s1"></span></p>
<p class="gmail-p2"><span class="gmail-s1"> </span><span class="gmail-s2">func</span><span class="gmail-s1"> rob(nums: [</span><span class="gmail-s3">Int</span><span class="gmail-s1">]) -> </span><span class="gmail-s3">Int</span><span class="gmail-s1"> {</span></p>
<p class="gmail-p2"><span class="gmail-s1"> </span><span class="gmail-s2">guard</span><span class="gmail-s1"> nums.count > </span><span class="gmail-s4">0</span><span class="gmail-s1"> </span><span class="gmail-s2">else</span><span class="gmail-s1"> { </span><span class="gmail-s2">return</span><span class="gmail-s1"> </span><span class="gmail-s4">0</span><span class="gmail-s1"> }</span></p>
<p class="gmail-p2"><span class="gmail-s1"> </span><span class="gmail-s2">let</span><span class="gmail-s1"> dp = Array.</span><span class="gmail-s2">init</span><span class="gmail-s1">(repeating: Array.</span><span class="gmail-s2">init</span><span class="gmail-s1">(repeating: </span><span class="gmail-s4">0</span><span class="gmail-s1">, count: nums.count),</span></p>
<p class="gmail-p2"><span class="gmail-s1"> count: </span><span class="gmail-s4">2</span><span class="gmail-s1">)</span></p>
<p class="gmail-p2"><span class="gmail-s1"> dp[</span><span class="gmail-s4">0</span><span class="gmail-s1">][</span><span class="gmail-s4">0</span><span class="gmail-s1">] = </span><span class="gmail-s4">0</span></p>
<p class="gmail-p2"><span class="gmail-s1"> dp[</span><span class="gmail-s4">0</span><span class="gmail-s1">][</span><span class="gmail-s4">1</span><span class="gmail-s1">] = nums[</span><span class="gmail-s4">0</span><span class="gmail-s1">]</span></p>
<p class="gmail-p2"><span class="gmail-s1"> </span><span class="gmail-s2">for</span><span class="gmail-s1"> i </span><span class="gmail-s2">in</span><span class="gmail-s1"> </span><span class="gmail-s4">1</span><span class="gmail-s1"> ..< nums.count {</span></p>
<p class="gmail-p2"><span class="gmail-s1"> dp[i][</span><span class="gmail-s4">0</span><span class="gmail-s1">] = max(dp[i - </span><span class="gmail-s4">1</span><span class="gmail-s1">][</span><span class="gmail-s4">0</span><span class="gmail-s1">], dp[i - </span><span class="gmail-s4">1</span><span class="gmail-s1">][</span><span class="gmail-s4">1</span><span class="gmail-s1">])</span></p>
<p class="gmail-p2"><span class="gmail-s1"> dp[i][</span><span class="gmail-s4">1</span><span class="gmail-s1">] = dp[i - </span><span class="gmail-s4">1</span><span class="gmail-s1">][</span><span class="gmail-s4">0</span><span class="gmail-s1">] + nums[i]</span></p>
<p class="gmail-p2"><span class="gmail-s1"> }</span></p>
<p class="gmail-p2"><span class="gmail-s1"> </span><span class="gmail-s2">return</span><span class="gmail-s1"> </span><span class="gmail-s4">0</span></p>
<p class="gmail-p2"><span class="gmail-s1"> }</span></p>
<p class="gmail-p2"><span class="gmail-s1">}</span></p></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br></div><br clear="all"><div><div class="gmail_signature"><i><font face="georgia, serif">best wishes for you </font></i></div></div>
</div>