Aha, a big hypothetical question. As unlikely as we are to face these ever in our lifetime, they are interesting questions to attempt to answer. And there is never really a right answer to them.
In the first case, there is definintely no legal obligation, unless one enacts a good samaritan law (similar to the one presented in the last episode of Seinfeld), or perhaps you are part of an actual rescue squad and in the right condition to do the rescue. As for moral obligation, that is dependent on the judgment of individuals and their own sense of moral code, which is never universal. Also, who has the moral authority to say that their sense of morality is the one for all to follow? However, if it was within my abilities as stated and thus the chance of success is high (such as at least 75%) and the chance of my own survival in the process is very high (such as at least 90%), I would do it. In reality it likely isn't within my abilities to a high enough degree, to be clear. I can swim, but I am far from a great swimmer, nor am I trained in water rescues, and I was never a lifeguard, if that holds any weight.
Is there a moral obligation to do something that will almost definitely get you killed, even with the greatest of skills? I would say definitely no. If there is a legal obligation in that case for anybody nearby, god help us all. We all have our limitations, and I think it matters to know and understand that. We can't save the world, but we can do our part where possible. To be obligated to do what is likely to get yourself killed in order to rescue a stranger puts one's own life value below that of the other. Volunteering is another story, but one should also not be foolish about it.