Linear algorithms for solving Stefan-like problems