If you leave the U.S. during your H-1B period and want to return to work, you need to find a new U.S. employer to file an application on your behalf. You will not need to go through the lottery again.
If you have previously been issued an H-1B and left the job within the 6-year period, but later wish to return to work in the U.S., you will need to find a new U.S. employer to file an I-129 petition on your behalf. Upon approval, you can either obtain an H-1B visa at a U.S. consulate abroad or enter the U.S. with your previously valid H-1B visa to work. This process is similar to an H-1B transfer, and no visa lottery is required.
To successfully use the remaining time on your H-1B, you must provide evidence proving your departure from the U.S. Such evidence includes stamps on your passport, I-94 records, ticket stubs, and travel itineraries.
If finding a job in the U.S. from abroad is too difficult, you can consider entering the U.S. on a B-1/B-2 or F-1 visa. After finding a job, you can then change your status within the U.S. back to H-1B.
Caution:
Both B-1/B-2 and F-1 visas have specific purposes and work restrictions, and you must not violate visa regulations.