Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public static int [ ] lockers ( boolean [ ] locker ) { / * * A school has 1 0 0 lockers and 1
public static int lockersboolean locker
A school has lockers and students. All lockers are closed on
the first day of school. As the students enter, the first student, denoted as
S opens every locker. Then the second student, S begins wtih the second
locker, denoted L and closes every other locker every second locker Student S begins with the
third locker, L and changes every third locker closes it if it was open,
and opens it if it was closed Student S begins with L and changes every fourth
locker. S starts with L and changes every fifth locker, and so on until student S changes L
After all the students have passed through the building and changed the lockers, which lockers are open?
find the indicies of lockers that are open and return them as counting numbersthis means index should be
so add to each index value you are storing in returned array
Args: array boolean: boolean array that represents the lockers, true means open locker, false means closed locker
Returns: int: array of open locker indicies as counting numbers
Your code goes here...
Step 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