This problem is based on a simple event ticket check. You have a list that shows whether each ticket was sold or not, and you want to know how many tickets are already taken.
In this version, the list uses 1 for a sold ticket and 0 for an unsold one. Your task is to count the number of ones.
For example, if the status list is [1,1,0,1], the answer is 3 because three tickets are marked as sold.
So the task is to scan the list and count how many sold tickets appear.
Example Input & Output
An empty list means there are no sold tickets to count.
Three of the tickets are marked as sold.
If no ticket is sold yet, the count stays 0.
Algorithm Flow

Solution Approach
A clean way to solve this is to use a counter that increases when you find a sold ticket.
Start by creating a variable like sold_count and set it to 0.
Then go through the ticket list one value at a time. For each value, check whether it is equal to 1.
The condition is:
If that condition is true, increase sold_count by 1.
After the loop finishes, the counter holds the total number of sold tickets, so that is the final answer.
The logic is simple because every ticket is checked in the same way.
Best Answers
Solutions Coming Soon
Verified best solutions for this Challenge are still being analyzed and will be available soon.
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
