Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the function using java: static int[] carParking(int n, int[][] available) { } Parking Attendant Charlie just started his new job as a parking attendant.
Complete the function using java:
static int[] carParking(int n, int[][] available)
{
}
Parking Attendant Charlie just started his new job as a parking attendant. Part of his job is to assign parking spaces from left to right in an n x n parking lot. Write a function that finds the row with the least cars and assigns the next available space in that row for Charlie to assign to the drivers as they enter the lot. Ex: n 5, the parking spots are denoted by row and space number. In your answer, indicate the Row number (1, 2, 3, 4, n) and the Space number (1, 2, 3, 4, 5, n) that is next available. Space Row 1: 1 2345 Row 2: 1 2 345 Row 3: 12345 Row 4: 12345 Row 5: 1 2345 Cars are parked from left to right, in the row with the least number of spaces. There will never be a gap in the full spaces (such as 1, 0, 0,1, 0) in any row. In the event of a tie, the first free spot is chosen 1100 1110 1000 11100 10000Step 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