IRS form 2555 qualifies you for the IRS Foreign Earned Income Exclusion, and is a simple form to fill out with the rest of your taxes, takes 5-20 minutes depending on how many countries you lived in that year.
IRS form 2555
IRS instructions
This is the official language of the IRS form 2555 physical presence test:
“You meet the physical presence test if you are physically present in a foreign country or countries 330 full days during any period of 12 consecutive months including some part of the year at issue. The 330 qualifying days do not have to be consecutive.”
Plainly, it doesn’t matter if you were absent from the United States between January 1st and December 31st to qualify, it only matters that you were not present in the United States for 330 of 365 consecutive days that include, in some part, the current tax year.
You could have been in the US until april, and then outside the US from May until the following april, and that’s fine to claim the FEIE and exclude a variable amount of your earned income tax as determined each year by the IRS (currently at $126,500 annually).
By tax year(Jan. 1 - Dec. 31) you were only out of the country for 270 days, but out of 365 calendar days, you were out of the country for 330+ days from May to April, and so you pass the physical presence test, which qualifies you for the Foreign Earned Income Exclusion.
It can be a US or non-US company that employs and pays you, you just have to be physically outside the US.