Solve using LinkedList


#1

It is working for most of the scenarios except one with lot of negative numbers. Anyone has any clue why it is not working?

`    class Solution {
public int candy(List<int> A) {
    
        if (A.Count == 1) return 1;

        LinkedList<int> candy_list = new LinkedList<int>(A.ToArray());

        int result = A.Count;

        for (LinkedListNode<int> node = candy_list.First; node != null; node = node.Next)
        {
            if (node.Previous != null && node.Value > node.Previous.Value) {
                result++;
            }
            if (node.Next != null && node.Value > node.Next.Value)
            {
                result++;
            }
        }

        return result;
}
}`