The British ambassador to the United States has resigned days after memos leaked showing him criticizing the administration of President Donald Trump.