Poisonous Plants - HackerRank

How to solve this without using stacks and queues or the editorial approach in O(N)?
Problem Link: https://www.hackerrank.com/challenges/poisonous-plants/problem
Can anyone elaborate on the stack approach as well?