Poisonous Plants - HackerRank

How to solve this without using stacks and queues or the editorial approach in O(N)?
Problem Link: Poisonous Plants | HackerRank
Can anyone elaborate on the stack approach as well?