'Algorithm confusion in codewars

So here is the problem:

The new "Avengers" movie has just been released! There are a lot of people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 dollars bill. A "Avengers" ticket costs 25 dollars.

Vasya is currently working as a clerk. He wants to sell a ticket to every single person in this line.

Can Vasya sell a ticket to each person and give the change if he initially has no money and sells the tickets strictly in the order people follow in the line?

Return YES, if Vasya can sell a ticket to each person and give the change. Otherwise return NO.

My code:

function tickets(peopleInLine) {
  var speakVasya = "";
  var vasyaValue = 0;
  for (var i = 0; i < peopleInLine.length; i++) {
    if (peopleInLine[i] - 25 > vasyaValue) {
      speakVasya = "NO";
      break;
    } else {
      vasyaValue += 25;
      speakVasya = "YES";
    }
  }
  document.write(speakVasya);
}


tickets([25, 25, 50]);

Live demo here https://jsfiddle.net/py234z11/1/

My problem is, according to codewars,my solution passes 7 tests but fails at 2, but i can't understand which ones as it doesn't give the arguements which puts in tickets function.



Solution 1:[1]

My C# solution for this problem, edited

public static string CanSellTickets(int[] peopleInLine) {

        int count25 = 0;
        int count50 = 0;

        for (var i = 0; i < peopleInLine.Length; i++) {
            if (peopleInLine[i] == 25) {
                count25++;
            }
            else if (peopleInLine[i] == 50) {
                if (count25 == 0) {
                    return "NO";
                }
                else {
                    count25--;
                    count50++;
                }
            }
            else if (peopleInLine[i] == 100) {
                if (count50 >= 1 && count25 >= 1) {
                    count25--;
                    count50--;
                }
                else if (count50 == 0 && count25 >= 3) {
                    count25 = count25 - 3;
                }
                else {
                    return "NO";
                }
            }
        }

        return "YES";
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1