Intuitively, one would say that cold water freezes faster, because it is already cold and therefore needs less time to cool down all the way to its freezing point. Hot water would need to be cooled more to get all the way to the freezing point, and it would therefore take longer to freeze it.
However, the fact that you ask this question shows that you may have heard the opposite. And indeed, it has been observed that there are certain cases when hot water does freeze faster than cold water. This is not always the case, though! And on top of that, it is not exactly known why this happens.
There are a number of different scientific explanations for this observation, which to some extent probably all play a role in this effect. Let me try to explain four of the main reasons below (if these rather lengthy explanations seem too boring or too overwhelming to you at this point, just skip the next four paragraphs and go directly to the end!):
- The first one has to do with the only difference between the two containers of water, and that is their temperature. Have you ever observed a pot of boiling water? What do you see? ... Steam is coming from the pot, right? This means that some water is so hot that it boils off, forms steam and leaves the pot. This in turn means that the amount of water that is left behind in the pot is getting less and less. Well, the same is true for warm water, except that it happens to a much smaller extent and we can't see it. But there is also water that leaves the container of warm water and therefore less warm water is left behind. The warmer the water, the more of it leaves the container as a gas (in other words, this also happens for the cold water, but not nearly as much as it does for the warm water). So if there is less warm water left in the container than there is cold water left, then it should take less time to freeze the warm water, simply because there is less of it left behind.
- The second possible explanation has to do with what else is in the water. What happens when you open a bottle of soda or carbonated water? It fizzes and bubbles form, right? That means that there are also gases in the water, which we sometimes can't see very well until we open the bottle of soda. What happens when you leave that bottle of soda sitting on your kitchen table for a day? ... It goes flat, which means that all the carbonation (= the gas) is gone. What happens to the bottle of soda when you put it in the fridge? ... It goes flat, too, but it takes much longer to do so. The same is true for "pure" water. It always contains some amount of gas, which we can't really see nor taste. And warm water contains less of these gases than cold water does (just like your warm bottle of soda contains less carbonation (= is more flat) than the cold soda does). It is possible that water cools quicker the more pure it is (= the less of these gases it contains). Since warm water has fewer of these gases in it, this could be another explanation for why it might cool faster, and therefore freeze faster.
- The third reasoning has to do with slight differences in the actual temperature within each of the water containers. Do you surf or have you ever gone swimming in the ocean? If so, you've probably noticed that the temperature of the water varies a little bit from one point to the other, even though the weather forecast only talked about one single water temperature. The same is true for a swimming pool. Even though there is only one temperature posted, sometimes you hit cold spots and sometime you hit spots that are a little warmer. Well, the same is true for the two containers of water. Even though their overall temperatures are "warm" and "cold", the actual temperatures will vary a little within each container. As it turns out, the warmer the water overall, the more of these warm spots you will have at the water surface, which makes it easier for the water to cool. So this would mean that it is easier (and therefore faster) for the warm water to cool.
- The fourth potential explanation has once again to do with what else is in the water. As mentioned in the second explanation above, the warm water contains fewer gases than the cold one does. This could affect another property of water when it comes to its cooling. It is not very likely you have seen this in everyday life, but there is a chance that water can be cooled down to a few degrees less than zero degrees Celsius without it actually freezing. It then suddenly freezes into a complete block of ice at once. This sounds most likely very strange, and going into the reasoning would go way too far at this point. But the fact that cold water has more of these gases in it could make it more prone to be cooled to less than zero degrees Celsius, and therefore make it freeze later (= slower) than the warm water. So all in all, you asked an excellent question, which is still not completely understood! The answers above are only potential explanations.