Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
