President Donald Trump has suggested Elon Musk buying TikTok could save it from being permanently banned in the US.