The Prophet salla Allahu alaihi wa sallam had said that there in prayer (valid) to an individual praying alone behind the row.
Scholars say that if an individual finds a space yet decides to pray alone, his prayer is invalid.
But if he tried his level best to find a gap but couldn’t, his prayer alone is acceptable.