If your laptop requires AC then an inverter is necessary.
However other laptops require DC and then it depends on what voltage.
Some laptops can be connected directly to a ships battery or use
a DC/DC converter depending on whether your boat operates on 12 or 24 volts
and whether your laptop needs 15, 19 or even 24 volts.
It probably pays not to buy the very cheapest inverters if you go that route.
They can provide less than ideal AC and are noisy and interfere with radio reception.