Your first solution breaks with the string 'xnox' (which should not produce any output as
), it just displays 'nx' which is undesired. Your second solution suffers from the same problem.
Whenever there are alternating x's and other chars (even x's as well) your solution is perfect, however it does not take into account that their can be multiple chars between x's. (mind you the original post did not mention this either but it's not unrealistic to assume this)