Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help to solve this simple coding problem, thanks! This coding problem can use any programming languages, Python or jave both okay Description: You've recently
Please help to solve this simple coding problem, thanks!
This coding problem can use any programming languages, Python or jave both okay
Description: You've recently started managing a theme park but have run into a problem: You're never sure if the park is empty or not when it's time to close for the night. Your equipment is so bad, you're not even sure your records are correct! You will be provided with an array of positive and negative integers representing a record of the comings and goings of groups inside the park for the day. Each integer represents the party size of a group either entering (positive) or exiting (negative) the park. Groups never split up or combine, and a valid record will never show a group leaving the park before they enter. In order to close the park for the day, you need the park to be empty. Write a function that returns 'CLOSE' if the park can safely close or 'OPEN' if there are still people in the park or the record is invalid. Note: Group sizes are not unique. There can be multiple parties of the same size in the park Examples: Input: [2,5,7,2,6,5] Output: 'OPEN' Explanation: 'A group of 5 and 6 left the park before entering, so this is an invalid log and the park must remain open.' Input: [9,9,8,8,9,9,9,9] Output: 'CLOSE' Explanation: ' 'The groups weren't unique, but all groups that entered the park have left. The park may close.' Language Python 3 (i) Q AuStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started