<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" 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/" > <channel><title>“Leona+”的评论</title> <atom:link href="http://leonax.net/comments/feed/" rel="self" type="application/rss+xml" /><link>http://leonax.net</link> <description>Enjoy Life</description> <lastBuildDate>Mon, 30 Apr 2012 02:26:09 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>EasySnap 对《经典面试题 之 在单调矩阵中查找元素》的评论</title><link>http://leonax.net/p/1984/find-element-in-monotonic-matrix/comment-page-1/#comment-12159</link> <dc:creator>EasySnap</dc:creator> <pubDate>Mon, 30 Apr 2012 02:26:09 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1984#comment-12159</guid> <description>好吧，用html tag试试 &lt;code&gt;// search value target in 2D grid int i = 0; int j = n -1; while ( (i &lt; n) &amp;&amp; (j &gt;= 0) ) { if (target == grid[j][j]) break; // found else if (grid[i][j] &lt; target) ++i; else --j; } // if both i and j are valid, the position was found. Otherwise, target was not found. &lt;/code&gt;</description> <content:encoded><![CDATA[<p>好吧，用html tag试试</p><div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">// search value target in 2D grid<br /> int i = 0;<br /> int j = n -1;<br /> while ( (i &lt; n) &amp;&amp; (j &gt;= 0) )<br /> {<br /> &nbsp; &nbsp; if (target == grid[j][j])<br /> &nbsp; &nbsp; &nbsp; &nbsp; break; // found<br /> &nbsp; &nbsp; else if (grid[i][j] &lt; target)<br /> &nbsp; &nbsp; &nbsp; &nbsp; ++i;<br /> &nbsp; &nbsp; else<br /> &nbsp; &nbsp; &nbsp; &nbsp; --j;<br /> }<br /> &nbsp; &nbsp; // if both i and j are valid, the position was found. Otherwise, target was not found.</div></td></tr></tbody></table></div> ]]></content:encoded> </item> <item><title>EasySnap 对《经典面试题 之 在单调矩阵中查找元素》的评论</title><link>http://leonax.net/p/1984/find-element-in-monotonic-matrix/comment-page-1/#comment-12158</link> <dc:creator>EasySnap</dc:creator> <pubDate>Mon, 30 Apr 2012 02:23:54 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1984#comment-12158</guid> <description>发现系统会改我的代码！难道正好是escape sequence？重贴被改的部分。 while ( ( i = 0 ) )</description> <content:encoded><![CDATA[<p>发现系统会改我的代码！难道正好是escape sequence？</p><p>重贴被改的部分。<br /> while ( ( i = 0 ) )</p> ]]></content:encoded> </item> <item><title>EasySnap 对《经典面试题 之 在单调矩阵中查找元素》的评论</title><link>http://leonax.net/p/1984/find-element-in-monotonic-matrix/comment-page-1/#comment-12157</link> <dc:creator>EasySnap</dc:creator> <pubDate>Mon, 30 Apr 2012 02:19:48 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1984#comment-12157</guid> <description>用主贴的解法，递归子问题不能保证是2个方阵。如何处理非方正原贴没写，否则我们可以用Master theorem分析下复杂度，估计不乐观：）如果假定每次都是在中点划分（也就是假定每次得到2个子方阵）的话，T(n) = 2T(n/2) + log n) =&gt; T(n) = Thera(n)。这种情况下，上界已经不止O(logN * logN)了。这个问题能派生出好几个小题，比如一维数组内找和为特定值的2个数或是3个数（3SUM）。真算是经典中的经典了。解法就是从左下（或右上）开始，如果当前点就是目标值则找到，否则可以根据当前点和目标值的大小关系相应排除当前点所在的一整行或一整列，反复迭代上述过程。因为每次迭代，矩阵长或宽中的一个会减一，显然算法能在O(n)时间内完成。// search value target in 2D grid int i = 0; int j = n -1; while ( (i = 0) ) { if (target == grid[j][j]) break; // found else if (grid[i][j] &lt; target) ++i; else --j; } // if both i and j are still valid, they record the position found . Otherwise, target cannot be found in grid.</description> <content:encoded><![CDATA[<p>用主贴的解法，递归子问题不能保证是2个方阵。如何处理非方正原贴没写，否则我们可以用Master theorem分析下复杂度，估计不乐观：）如果假定每次都是在中点划分（也就是假定每次得到2个子方阵）的话，T(n) = 2T(n/2) + log n) =&gt; T(n) = Thera(n)。这种情况下，上界已经不止O(logN * logN)了。</p><p>这个问题能派生出好几个小题，比如一维数组内找和为特定值的2个数或是3个数（3SUM）。真算是经典中的经典了。</p><p>解法就是从左下（或右上）开始，如果当前点就是目标值则找到，否则可以根据当前点和目标值的大小关系相应排除当前点所在的一整行或一整列，反复迭代上述过程。因为每次迭代，矩阵长或宽中的一个会减一，显然算法能在O(n)时间内完成。</p><p>// search value target in 2D grid<br /> int i = 0;<br /> int j = n -1;<br /> while ( (i = 0) )<br /> {<br /> if (target == grid[j][j])<br /> break; // found<br /> else if (grid[i][j] &lt; target)<br /> ++i;<br /> else<br /> &#8211;j;<br /> }<br /> // if both i and j are still valid, they record the position found . Otherwise, target cannot be found in grid.</p> ]]></content:encoded> </item> <item><title>Shuhai Shen 对《经典面试题 之 在单调矩阵中查找元素》的评论</title><link>http://leonax.net/p/1984/find-element-in-monotonic-matrix/comment-page-1/#comment-12152</link> <dc:creator>Shuhai Shen</dc:creator> <pubDate>Mon, 16 Apr 2012 07:10:28 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1984#comment-12152</guid> <description>我没仔细算过，呵呵。</description> <content:encoded><![CDATA[<p>我没仔细算过，呵呵。</p> ]]></content:encoded> </item> <item><title>Shuhai Shen 对《百度之星 2010 题目篇》的评论</title><link>http://leonax.net/p/1822/astar-2010-the-contest/comment-page-1/#comment-12151</link> <dc:creator>Shuhai Shen</dc:creator> <pubDate>Mon, 16 Apr 2012 07:09:18 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1822#comment-12151</guid> <description>嗯，要算距离。差不多，或者是在行动受阻（遇到敌军）或者计划有变（矿被别人采掉了）的时候再算。</description> <content:encoded><![CDATA[<p>嗯，要算距离。差不多，或者是在行动受阻（遇到敌军）或者计划有变（矿被别人采掉了）的时候再算。</p> ]]></content:encoded> </item> <item><title>haipeng31 对《百度之星 2010 题目篇》的评论</title><link>http://leonax.net/p/1822/astar-2010-the-contest/comment-page-1/#comment-12150</link> <dc:creator>haipeng31</dc:creator> <pubDate>Sun, 15 Apr 2012 15:48:47 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1822#comment-12150</guid> <description>弱问二分匹配前是不是要先A*算出每个坦克到所有未占领矿点的最短距离，然后每次计算下一次命令是不是都要做这两步。不知道是不是这个意思，菜鸟求助。</description> <content:encoded><![CDATA[<p>弱问二分匹配前是不是要先A*算出每个坦克到所有未占领矿点的最短距离，然后每次计算下一次命令是不是都要做这两步。不知道是不是这个意思，菜鸟求助。</p> ]]></content:encoded> </item> <item><title>oyz 对《经典面试题 之 在单调矩阵中查找元素》的评论</title><link>http://leonax.net/p/1984/find-element-in-monotonic-matrix/comment-page-1/#comment-12142</link> <dc:creator>oyz</dc:creator> <pubDate>Thu, 12 Apr 2012 06:46:40 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1984#comment-12142</guid> <description>您好，关于这个算法的复杂度我粗略地算了下，怎么是O(n)呢？ 请大牛仔细证明下，看是不是我算错了，另外，这个题目我知道另外 一种解法，复杂度是O（n）的，您看看对么： 以您文中的例子为例子， 从A17开始比较，若小于则向左走，若大于则向下走，如果碰到需要回退（即向上走和向右走）或者已越界，则证明矩阵中不存在该数，否则一定可以找到对应的数字。</description> <content:encoded><![CDATA[<p>您好，关于这个算法的复杂度我粗略地算了下，怎么是O(n)呢？<br /> 请大牛仔细证明下，看是不是我算错了，另外，这个题目我知道另外<br /> 一种解法，复杂度是O（n）的，您看看对么：<br /> 以您文中的例子为例子，<br /> 从A17开始比较，若小于则向左走，若大于则向下走，如果碰到需要回退（即向上走和向右走）或者已越界，则证明矩阵中不存在该数，否则一定可以找到对应的数字。</p> ]]></content:encoded> </item> <item><title>Phung Millraney 对《在连接字符串中使用不同的SQL Server的验证方式》的评论</title><link>http://leonax.net/p/2652/using-different-authentication-mode-in-connection-string/comment-page-1/#comment-12139</link> <dc:creator>Phung Millraney</dc:creator> <pubDate>Tue, 10 Apr 2012 03:24:11 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=2652#comment-12139</guid> <description>Please inform me it labored proper? I dont need to sumit it again if i shouldn&#039;t have to! Both the weblog glitced out or i&#039;m an fool, the second possibility doesnt surprise me lol. thanks for an excellent weblog!  Anyway, in my language, there aren&#039;t a lot good source like this.</description> <content:encoded><![CDATA[<p>Please inform me it labored proper? I dont need to sumit it again if i shouldn&#8217;t have to! Both the weblog glitced out or i&#8217;m an fool, the second possibility doesnt surprise me lol. thanks for an excellent weblog!  Anyway, in my language, there aren&#8217;t a lot good source like this.</p> ]]></content:encoded> </item> <item><title>土木坛子 对《个人博客在国内的访问加速》的评论</title><link>http://leonax.net/p/2997/acceleration-of-personal-blog-from-mainland/comment-page-1/#comment-12130</link> <dc:creator>土木坛子</dc:creator> <pubDate>Thu, 22 Mar 2012 22:33:08 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=2997#comment-12130</guid> <description>还是买一家较好的主机服务可靠。</description> <content:encoded><![CDATA[<p>还是买一家较好的主机服务可靠。</p> ]]></content:encoded> </item> <item><title>土木坛子 对《从WordPress同步到其它博客和微博的方法[更新：2010/10/12]》的评论</title><link>http://leonax.net/p/1876/way-to-sync-wordpress-to-other-blogs/comment-page-1/#comment-12129</link> <dc:creator>土木坛子</dc:creator> <pubDate>Thu, 22 Mar 2012 22:31:07 +0000</pubDate> <guid isPermaLink="false">http://leonax.net/?p=1876#comment-12129</guid> <description>Follow5 已经西去了。</description> <content:encoded><![CDATA[<p>Follow5<br /> 已经西去了。</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc (User agent is rejected)
Object Caching 646/666 objects using apc

Served from: leonax.net @ 2012-05-21 01:13:11 -->
