End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.
times array based on arrival times.free_chairs for available chairs and occupied_chairs for chairs that are currently occupied.free_chairs with all possible chair numbers (from 0 to n-1).times array.
a. For each friend, release any chairs from occupied_chairs whose departure time is less than or equal to the current arrival time.
b. Assign the smallest available chair from free_chairs to the current friend.
c. If the current friend is the targetFriend, return the assigned chair number.
d. Add the current friend's departure time and assigned chair number to occupied_chairs.targetFriend.