<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Largest number of integers in a row within an array' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Largest number of integers in a row within an array' posted on the 'Java' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Thu, 20 Jun 2013 02:45:08 -0700</pubDate>
    <lastBuildDate>Thu, 20 Jun 2013 02:45:08 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Largest number of integers in a row within an array</title>
      <link>http://www.programmersheaven.com/mb/java/419312/419312/largest-number-of-integers-in-a-row-within-an-array/</link>
      <description>I an Integer array with only ones and zeros. What would be the Simplest way to count the largest row of zeros that appear within that array. Such as if there was 5 zeros back to back at the beginning of the array and another 7 zeros in a row at the end of the array. that answer would be  seven.&lt;br /&gt;
Im assuming there would have to be a way to compare the last stored highest number and the newest.&lt;br /&gt;
&lt;br /&gt;
Thanks for anyhelp given.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/419312/419312/largest-number-of-integers-in-a-row-within-an-array/</guid>
      <pubDate>Mon, 25 Oct 2010 08:03:32 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Largest number of integers in a row within an array</title>
      <link>http://www.programmersheaven.com/mb/java/419312/419510/re-largest-number-of-integers-in-a-row-within-an-array/#419510</link>
      <description>That problem is closely related to finding the maximum number within an array.  It can be done sequentially in O(n) time where n is proportional to length of array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method wasn't tested by compiling and running but it might work and is definitely close to what you want:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
int getLengthOfMaximumSequenceOfZeros(int a[])
{

int maxLen=0;
int curLen=0;

// loop through all elements in the array.
for (int i=0;i&amp;lt;a.length;i++)
{
  if (a[i]==0)
  {
     curLen++; // sequence is getting longer by 1.
  }
  else // restarting new sequence of zeros
  {
    // if the sequence ending is longer, remember its length.
    if (curLen&amp;gt;maxLen) 
       maxLen = curLen;

    curLen=0; // current sequence has length 0 again.
  }
}
// if longest sequence goes right to the end of array
if (curLen&amp;gt;maxLen) 
   maxLen = curLen;

return maxLen;
}
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/419312/419510/re-largest-number-of-integers-in-a-row-within-an-array/#419510</guid>
      <pubDate>Wed, 03 Nov 2010 13:44:43 -0700</pubDate>
      <category>Java</category>
    </item>
  </channel>
</rss>