Deductions & credits

Thank you so much for your reply!

I was in the US as a J1:
2011: 30 days
2012: 90 days
2016: 5 months
2017, 2018, 2019: Full year
Would that count for 5 years? I'm not sure if I have to be the entire year in order for it to count.

Also, when does the H1B start counting? When I get the stamp on my passport or when I get the letter?
I got the approval letter in December 2018, and the stamp on May 2019.
If it's when I get the approval letter, and since I got in 2018. Wouldn't that make me a resident for 2019?
Thanks!