<?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>incresing Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/incresing/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/incresing/</link>
	<description></description>
	<lastBuildDate>Sun, 02 Sep 2018 05:31:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>incresing Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/incresing/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 896. Monotonic Array</title>
		<link>https://zxi.mytechroad.com/blog/algorithms/array/leetcode-896-monotonic-array/</link>
					<comments>https://zxi.mytechroad.com/blog/algorithms/array/leetcode-896-monotonic-array/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 02 Sep 2018 05:31:07 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[decresing]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[incresing]]></category>
		<category><![CDATA[monotonic]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=3798</guid>

					<description><![CDATA[<p>An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i &#60;= j, A[i] &#60;= A[j].  An array A is monotone&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/array/leetcode-896-monotonic-array/">花花酱 LeetCode 896. Monotonic Array</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>An array is <em>monotonic</em> if it is either monotone increasing or monotone decreasing.</p>
<p>An array <code>A</code> is monotone increasing if for all <code>i &lt;= j</code>, <code>A[i] &lt;= A[j]</code>.  An array <code>A</code> is monotone decreasing if for all <code>i &lt;= j</code>, <code>A[i] &gt;= A[j]</code>.</p>
<p>Return <code>true</code> if and only if the given array <code>A</code> is monotonic.</p>
<h1><strong>Solution: </strong></h1>
<p><div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  bool isMonotonic(vector&lt;int&gt;&amp; A) {
    bool inc = true;
    bool dec = true;
    
    for (int i = 1; i &lt; A.size(); ++i) {
      inc &amp;= A[i] &gt;= A[i - 1];
      dec &amp;= A[i] &lt;= A[i - 1];
    }
    
    return inc || dec;
  }
};</pre><p></div><h2 class="tabtitle">Java</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">class Solution {
  public boolean isMonotonic(int[] A) {
    boolean inc = true;
    boolean dec = true;
    
    for (int i = 1; i &lt; A.length; ++i) {
      inc &amp;= A[i] &gt;= A[i - 1];
      dec &amp;= A[i] &lt;= A[i - 1];
    }
    
    return inc || dec;
  }
}</pre><p></div><h2 class="tabtitle">Python</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag"># Author: Huahua
class Solution:
  def isMonotonic(self, A):    
    inc = True;
    dec = True;
    
    for i in range(1, len(A)):
      inc = inc and A[i] &gt;= A[i - 1]
      dec = dec and A[i] &lt;= A[i - 1]    
    
    return inc or dec;</pre><p></div></div></p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/array/leetcode-896-monotonic-array/">花花酱 LeetCode 896. Monotonic Array</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/algorithms/array/leetcode-896-monotonic-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
