The atomic number of hydrogen is 1 so it has 1 electron in its outer shell. The atomic number of oxygen is 8 so it has 6 electron in its outer shell. Oxygen can share 1 electron with one hydrogen atom and a second electron with a second hydrogen atom, which has the effect of allowing all atoms to have a complete outer shell.