Formerly homeless teen is accepted to Stanford University Megan Faircloth and her family lived in hotels, a shelter and even their car.

 -- Starting in November 2015, Megan Faircloth bounced around from relatives' homes, hotels, a shelter and even her family's car with her two sisters and mother.

The 17-year-old would turn to Gloria Gaynor's "I Will Survive" and read books about others who had triumphed over adversity to help get her out of a funk.

Even though she was homeless, she was completing her junior year at East Wake High School in Wendell, North Carolina.

"Every day when we got home from school, my mom would have to drive around looking for money for a hotel room or a motel room and it was difficult because at one point we would get home around 12 [a.m.]," she told ABC affiliate WTVD-TV. "We wouldn't get home -- we would get to where we were going to sleep that night around 12 -- and then I had to start my homework and it was exhausting running around all day."

She continued, "We didn't have much money for food half the time either and that was difficult. Sometimes I had to do my homework outside or in our car or in public parks, which was difficult, if the homework required internet or something."

Her hard work, perseverance -- and listening to Gaynor -- paid off. She recently graduated from East Wake and was ranked No. 1 in her class with a 5.25 grade point average. Despite her troubled home life, she excelled in advanced-placement classes and participated in school clubs. Most importantly, Megan was accepted to Stanford University.

"At one point, I think ... my biggest low was when we were outside and it started raining and it was windy outside and I was trying to pin down my homework with all of my books and stuff like that and it started raining on my homework and I was like, 'This can either be the end or this is the beginning of me fighting on and deciding to go through all of this and try my best,'" she said. "I just tried to keep my spirit up."

In 2015, she and her family were living in a rented house. They did not have a lease so when the homeowner died suddenly, they were evicted. Megan said they had three days' notice to leave.

Soon afterward, her mother, Melva Faircloth, had to have surgery to remove a tumor. Recovery left her unable to work. Relatives helped them out financially. Megan said they stayed with relatives when they could but were forced to live in hotel rooms, their car and a shelter.

When she was starting to apply to college, she didn't even have an address. But, Megan said, Stanford had expressed interest in her that summer and that motivated her.

"I really carried that through me ... before then, I hadn't really thought about Stanford that much or the possibility of going to one of the top, like a prestigious school like that, and I really would've been satisfied with going to any college at that point, 'cause i just wanted an education," she said.

By October 2016, the family had permanently moved in with a family member.

Melva Faircloth said that through it all, her daughters had kept their sense of humor and had been a source of encouragement for her. She said she was happy that the family's circumstances had not affected how Megan viewed life or stopped her from pursuing a higher education.

"I knew Megan has a lot of determination and drive and maturity, and to be able to overcome all that and still make good grades, I'm so proud of her, you know," Melva Faircloth said. "I mean, she came out stronger because of all of it."

ABC affiliate WTVD-TV contributed to this story.