That’s a misunderstanding of the spec. The ask is to put in at least one label if there is space (when previously there were none). Filling all available space with redundant labels is not the ask.
# Label all streets as much as possible
for (each street on screen):
while (that street has room for a label): # (even if already labeled)
put a label on that street # i.e. an additional one
yours is: # Try to label unlabeled streets
for (each street on screen)
if (no label on screen for that street): # if unlabeled
if (street has room for a label): # ...can we fix?
put a label on that street # ...then fix
(I would usually write this with an && rather than nested if's but I know mobile makes you scroll sideways)As a followup, could you please define "street has room for a label"? When do you consider that a street has room for a label?