title: HackerRank Challenge : Find total number of days Plants die
body: <blockquote>
    <p><strong>Problem Statement</strong></p>
    
    <p>There are N plants in a garden. Each of these plants has been added
    with some amount of pesticide. After each day, if any plant has more
    pesticide than the plant at its left, being weaker than the left one,
    it dies. You are given the initial values of the pesticide in each
    plant. Print the number of days after which no plant dies, i.e. the
    time after which there are no plants with more pesticide content than
    the plant to their left.</p>
    
    <p><strong>Input Format</strong></p>
    
    <p>The input consists of an integer N. The next line consists of N
    integers describing the array P where P[i] denotes the amount of
    pesticide in plant i.</p>
    
    <p><strong>Constraints</strong> </p>
    
    <p>1 ≤ N ≤ 100000 <br> 0 ≤ P[i] ≤ 109</p>
    
    <p><strong>Output Format</strong></p>
    
    <p>Output a single value equal to the number of days after which no
    plants die.</p>
    
    <p><strong>Sample Input</strong></p>
    
    <p>7 6 5 8 4 7 10 9</p>
    
    <p><strong>Sample Output</strong></p>
    
    <p>2</p>
    
    <p><strong>Explanation</strong></p>
    
    <p>Initially all plants are alive.<br>  Plants = {(6,1), (5,2), (8,3), (4,4),
    (7,5), (10,6), (9,7)}.<br> Plants[k] = (i,j) => jth plant has pesticide
    amount = i.<br>  After the 1st day, 4 plants remain as plants 3, 5, and 6
    die.<br>  Plants = {(6,1), (5,2), (4,4), (9,7)}.<br>  After the 2nd day, 3
    plants survive as plant 7 dies.<br> Plants = {(6,1), (5,2), (4,4)}.<br>  After
    the 3rd day, 3 plants survive and no more plants die.<br>  Plants =
    {(6,1), (5,2), (4,4)}.<br>  After the 2nd day the plants stop dying.</p>
  </blockquote>
  
  <p><strong>Challenge Link :</strong>  <a href="https://www.hackerrank.com/contests/countercode/challenges/poisonous-plants" rel="nofollow">HackerRank : Poisonous Plant</a></p>
  
  <p><strong>My Submission :</strong> <a href="https://www.hackerrank.com/contests/countercode/challenges/poisonous-plants/submissions/code/3542702" rel="nofollow">HackerRank Submission Link</a></p>
  
  <p><strong>Failed Test Case 1 :</strong> <a href="https://hr-testcases.s3.amazonaws.com/8763/input15.txt?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&amp;Expires=1438602531&amp;Signature=QhGv1cjkTHm%2FlUt7VryDgNFiV0o%3D&amp;response-content-type=text%2Fplain" rel="nofollow">Input</a> <a href="https://hr-testcases.s3.amazonaws.com/8763/output15.txt?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&amp;Expires=1438602533&amp;Signature=D%2BwG7kHq6HAvcxmHHy04AxBvrSg%3D&amp;response-content-type=text%2Fplain" rel="nofollow">Output</a></p>
  
  <p><strong>Failed Test Case 2 :</strong> <a href="https://hr-testcases.s3.amazonaws.com/8763/input22.txt?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&amp;Expires=1438602547&amp;Signature=d91hlPxjscTw0zGxmHYnl%2BAf1EI%3D&amp;response-content-type=text%2Fplain" rel="nofollow">Input</a> <a href="https://hr-testcases.s3.amazonaws.com/8763/output22.txt?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&amp;Expires=1438602550&amp;Signature=Ol8E1LWOTaTSmYA4yr1vGfHAZbg%3D&amp;response-content-type=text%2Fplain" rel="nofollow">Output</a></p>
  
  <p><strong>My Code so Far :</strong><br></p>
  
  <pre><code>total = int(raw_input())
  plants = map(int,raw_input().split())
  num_deaths = 1
  day = 0
  while num_deaths &gt; 0:
      num_deaths = 0
      temp_plants = []
      day += 1
      for i in range(1, len(plants)):
          if plants[i] &gt; plants[i - 1]:
              num_deaths += 1
              continue
          else:
              temp_plants.append(plants[i])
      plants = temp_plants
  print(day - 1)
  </code></pre>
  
  <p>It still fails a few test cases. Any suggestions/advice ?</p>