answer
with the same length as heights
to store the number of people each person can see.heights
array from right to left (from the last person to the first person).count
to 0.count
.count
by 1 because the current person can see the next taller person.answer[i]
to count
for the current person.answer
array.