I was solving a code on leet code and noticed that the time complexity of the first algorithm is more than the second algorithm even though they seem to be pretty similar.