By Eliza Shapiro and K.K. Rebecca Lai

Donna Lennon will never forget when she learned she had won a seat at Stuyvesant High School, one of the nation’s most revered and selective public schools.

Ms. Lennon was sitting in English class in mostly low-income and black East New York, Brooklyn, in the spring of 1981 when a guidance counselor delivered the good news. The class erupted in cheers. “I couldn’t speak,” said Ms. Lennon, now 51 and a lawyer.

Four years later, she graduated from Stuyvesant — then one of the city’s three specialized high schools — alongside Dianne Morales, who said it “was a diamond in the middle of the desert” for students like her.

Ms. Morales, who is Puerto Rican and grew up in Bedford-Stuyvesant, Brooklyn, crammed for exams and completed hours of homework each night, sometimes on long commutes, alongside classmates from every corner of the city.

“All of New York City was new to me,” she said, remembering that she was exposed to loft parties in SoHo and friends’ luxurious apartments near Washington Square Park’s grand marble arch. At Stuyvesant, Ms. Morales, now the chief executive of a nonprofit, said she “learned there was so much more out there for me.”

In interviews, more than a dozen black and Hispanic students who graduated from New York City’s specialized high schools from 1975 to 1995 described the schools as oases for smart children from troubled neighborhoods. But the alumni said they were anguished that the schools have since lost nearly all of their black and Hispanic students.