The contestants score the sum of points according to their position on the leaderboard and the public vote.
For example, if there are 10 contestants left in the competition who all had different scores then the contestant who is highest on the leaderboard gets 10 points and the one who is bottom of leader board gets 1 point.
The one with the most public votes get 10 points and the one with the least gets 1, which of course will not necessarily match their position on the leaderboard.
If there is a tie on the leaderboard then the contestants share the same score, so in our example of 10 contestants, if top of the leaderboard scores 36, but the next two score 35, then both those contestants get 9 points. If there are no other ties, then everyone below them get one point more than they would.
This is why it is mathematically possible to be top of the leaderboard but still be in the bottom two in later weeks, if you are not popular.