Hi,
I suspect that there is an error in the test-case #2, see the details below.
The error is that then the last instruction runs the only Empty spot is available, it is spot number 1.
See the debugger snippet below:
parking = {Car[6]@976}
0 = null
1 = {Car@997} “Medium Red Ford”
2 = {Car@998} “Small Red Tesla”
3 = {Car@999} “Large Green Honda”
4 = {Car@1000} “Small Red Tesla”
5 = {Car@1001} “Large Black Ferrari”
See also the output for the test-case #2.
Cheers,
Roman
6
13
park 2 Medium Red Ford
park 4 Large Green Honda
print_free_spots
print 2
print 3
park 2 Small Red Tesla
print 2
print 3
park 3 Small Red Tesla
print 5
print_free_spots
park 3 Large Black Ferrari
print_free_spots
Your Output
4
Medium Red Ford
Empty
Medium Red Ford
Small Red Tesla
Small Red Tesla
2
1
Expected Output
4
Medium Red Ford
Empty
Medium Red Ford
Small Red Tesla
Small Red Tesla
2
2
LLD design problems are not upto the mark and their solution as well. In this problem no pricing strategy (rate-card), no support for different vehicle type, no support for multiple parking lots.
Entity/relationship design are missing. One should follow educative.io
output of test 2 1st part should be as below as we should using rotating queue
4
Medium Red Ford
Empty
Medium Red Ford
Small Red Tesla
Small Red Tesla
2
1
why there are no solutions in java?
When will the java solutions be available?
When will c++ solution be available
Plus 1 on this (testcase #2 is wrong). Three cars got parked so there should only be 1 free spot left at the end.